Home › Forums › General Issues › Dynamically select option with image? › Reply To: Dynamically select option with image?
Ok this somehow worked out but still having trouble with how to display the fields on the theme page!!
How do I echo the image in the post page?
function my_acf_load_field( $field )
{
// reset choices
$field['choices'] = array();
// load repeater from the options page
if(get_field('teams', 'option'))
{
// loop through the repeater and use the sub fields "value" and "label"
while(has_sub_field('teams', 'option'))
{
$value = get_sub_field('team_name');
$label = get_sub_field('team_name');
$team_logo = get_sub_field('team_logo');
$field['choices'][ $value ] = $label;
}
}
// Important: return the field
return $field;
}
// v4.0.0 and above
add_filter('acf/load_field/name=away_team', 'my_acf_load_field');
add_filter('acf/load_field/name=home_team', 'my_acf_load_field');
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.