Support

Account

Home Forums Backend Issues (wp-admin) Dynamically populate a select field’s choices from the options page EXTENDED Reply To: Dynamically populate a select field’s choices from the options page EXTENDED

  • Hi @jrstaatsiii

    All you will need to do is loop through all the rows from the options page repeater, and look for a match in the $title with that of which was selected on the post.

    Something like this should work:

    
    <?php 
    
    // vars
    $title = get_field('select_field');
    $image = false;
    $link = false;
    
    // find matching row
    if( have_rows('repeater_field', 'option') )
    {
    	while( have_rows('repeater_field', 'option' )
    	{
    		the_row();
    		
    		if( get_sub_field('title') == $title )
    		{
    			$image = get_sub_field('image');
    			$link = get_sub_field('link');
    		}
    	}
    }
    
    // echo
    echo '<img src="' . $image . '" />'
    
    // etc...
    
     ?>