Home › Forums › Add-ons › Repeater Field › Repeater field with IF/ELSE based on sub_field value › Reply To: Repeater field with IF/ELSE based on sub_field value
In the admin,
I have these four rows of fields (post type / qty per row):
inventory 4
liquidation 4
auction 8
studies 8
As a test, if I run this code:
<?php switch ($type):
case 'auction': ?>
<?php the_sub_field('content_type'); ?>
<?php the_sub_field('items_per_row'); //echo $wp_query->request;?>
<?php break; case 'liquidation': ?>
<?php the_sub_field('content_type'); ?>
<?php the_sub_field('items_per_row'); //echo $wp_query->request;?>
<?php break; case 'inventory': ?>
<?php the_sub_field('content_type'); ?>
<?php the_sub_field('items_per_row'); //echo $wp_query->request;?>
<?php break; case 'studies': ?>
<?php the_sub_field('content_type'); ?>
<?php the_sub_field('items_per_row'); //echo $wp_query->request;?>
<?php break; default: ?>
<?php echo 'No posts to show'; ?>
<?php break; endswitch; ?>
I get:
inventory 4 liquidation 4 auction 8 studies 8
Which is correct. It’s when I replace the sub_fields in those switch cases, or the if/else statements that the loop stops on the first one.. and I get:
inventory 4
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.