Support

Account

Home Forums General Issues Dynamically select option with image?

Solving

Dynamically select option with image?

  • Hi how do I add a dynamical select from option page?
    I made a Option page with a repeater and included these fields:
    -title
    -image

    and what I want now is to be able to add a select form into a post how do I achieve that?

    this is driving me crazy please help!!

  • 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');
    
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.