Support

Account

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