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 "";
} ?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744726717a4590223.html
评论列表(0条)