Support

Account

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');