最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - ElseIf Statement with ACF Group field

programmeradmin0浏览0评论

I wrote this code to show certain field contents depending on the selection of the select field. Unfortunately, something doesn't work with the Elseif loop

$selection = get_field('location_select');

if ($selection == 'Leipzig' ) { ?>

<?php if( have_rows('leipzig', 4136) ): //child group field
 while( have_rows('leipzig', 4136) ): the_row();?>


<ul>
    <li>Bundesland: <?php the_sub_field('location_bundes_le',4136); ?></li>
    <li>Einwohner: <?php the_sub_field('location_einw_le', 4136); ?></li>
    <li>Fläche: <?php the_sub_field('location_area_le',4136); ?></li>
    </ul>
     <?php endwhile; ?>
           <?php endif; ?>
        <?php }?>
<?php
elseif ($selection == 'Dresden' ) {?>
<?php if( have_rows('dresden', 4136) ): //child group field
while( have_rows('dresden', 4136) ): the_row(); ?>
<ul>
    <li>Bundesland: <?php the_sub_field('location_bundes_dd',4136); ?></li>
    <li>Einwohner: <?php the_sub_field('location_einw_dd', 4136); ?></li>
    <li>Fläche: <?php the_sub_field('location_area_dd', 4136); ?></li>
 </ul>  

    <?php endwhile; ?>
           <?php endif; ?>
       <?php } ?>

<?php
elseif ($selection == 'Frankfurt' ) { ?>
<?php if( have_rows('frankfurt', 4136) ): //child group field
while( have_rows('frankfurt', 4136) ): the_row(); ?>             
<ul>
    <li>Bundesland: <?php the_sub_field('location_bundes_fr',4136); ?></li>
    <li>Einwohner: <?php the_sub_field('location_einw_fr',4136); ?></li>
    <li>Fläche: <?php the_sub_field('location_area_fr', 4136); ?></li>

 <?php endwhile; ?>
        <?php endif; ?>
        <?php } ?>  
<?php
else {
    echo "";
 } ?>
发布评论

评论列表(0)

  1. 暂无评论