Support

Account

Home Forums General Issues Dynamically Output Options Page Data Based on Checkbox

Unread

Dynamically Output Options Page Data Based on Checkbox

  • I am trying to dynamically output data from the options page based on which checkboxes are selected on a post.

    The first step is to take the Options page options for a repeater field and output them as checkbox options on the post. I have done this via this page. This is working great. Only different is I am using a counter as the value vs. a custom field (so value for checkboxes is 1, 2, 3, etc.).

    The next step is to loop through the options page content, but only show the options that correspond to the options checked on the post page. This is where I am having issues. I have the basic repeater loop to loop through the options, but I can’t seem to figure out the conditional that should be used with it to only output the data that aligns with options checked on the post page.

    This is the repeater field code I have now:

    if( have_rows('my_select_values', 'options') ):
    
    		$count=1;
        while ( have_rows('my_select_values', 'options') ) : the_row();
    
        		if ($count == the_field('colors')) {
        			//NEED SOME SORT OF CONDITIONAL TO ONLY OUTPUT OPTIONS THAT ARE CHECKED ON POST PAGE
    
    	        the_sub_field('label', 'options');
    	        echo "<br/>";
    	        the_sub_field('image', 'options');
        		}
            $count++;
        endwhile;
    else :
        // no rows found
    endif;

    Any help would be great.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.