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...
?>
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.