###前提・実現したいこと
wordpress カスタム投稿タイプ、カスタムフィールドの編集をしております。
Advanced Custom Fields の Repeater Fieldを使って カテゴリーの型を作って量産できるようにしたいと思っています。
入れ子の if while に閉じタグをどのようにおけば良いのかわからず困ってます。
実現したい構造
導入事例紹介文
事例(リピートする)
ーメイン画像
ー背景
ー導入製品(リピートする)
ーー品番
ーー説明
ーー画像(リピートする)
正しい閉じタグの置き場所を御指南いただければ幸いです。
###該当のソースコード
php
1<!--導入事例紹介文--> 2 <div class="mainArea"> 3 <p class="para"><?php echo the_field('case_study_explain');?></p> 4 5 <!--事例の始まり リピートする--> 6 <?php if(have_rows('case')): ?> <!--1--> 7 <?php while(have_rows('case')): the_row(); ?> <!--2--> 8 <?php $back = get_sub_field('case_background'); 9 $bg = $back['url']; ?> 10 <div class="caseStudy"> 11 <img class="main_back" src="<?php echo $bg; ?>" width="100%" height="209px" alt="背景画像"> 12 <!--事例メイン画像の背景↑--> 13 <?php $image = get_sub_field('case_main_img'); 14 $url = $image['url']; ?> 15 <div class="caseStudy__mainImg"><img src="<?php echo $url; ?>" alt="交通機関"></div> 16 <!--メイン画像--> 17 <div class="caseStudy__textWrap"> 18 19 <!--導入製品 リピートする--> 20 <?php $product = get_sub_field('case_product'); ?> 21 <?php if(have_rows('case_product')): ?> <!--3--> 22 <?php while(have_rows('case_product')): the_row(); ?> <!--4--> 23 <?php $num = get_sub_field('case_product_number'); ?> 24 <h3 class="caseStudy__tit"><?php echo $num;?></h3> 25 <!--製品番号↑--> 26 <?php $explain = get_sub_field('case_product_explain'); ?> 27 <p class="caseStudy__text"><?php echo $explain;?></p> </div> 28 <!--製品説明↑--> 29 <div class="caseStudy__imgList" id="slider"> 30 <div id="slider__inner"> 31 <ul class="caseStudy__imgList_wrap"> 32 <?php if(have_rows('case_product_images')): ?> <!--5--> 33 <?php while(have_rows('case_product_images')): the_row(); ?> <!--6--> 34 <?php $imgs = get_sub_field('case_product_img'); 35 $img = $imgs['url'];?> 36 <li class="item"><img src="<?php echo $img; ?>" alt="" height="174" width="174"><span class="over"></span></li> 37 <!--画像集↑ リピートする--> 38 <?php endwhile; ?> <!--/6--> 39 </ul> 40 <?php endif; ?> <!--/5--> 41 </div> 42 <?php endwhile; ?> <!--/4--> 43 44 <?php endif; ?> <!--/3--> 45 <?php endwhile; ?> <!--/2--> 46 </div> 47 </div> 48 <?php endif; ?> <!--/1--> 49 </div>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。