Support

Account

Home Forums Backend Issues (wp-admin) Relationship field – get ACF field values from custom options page

Solved

Relationship field – get ACF field values from custom options page

  • Am I able to get ACF field values from an ACF options page when creating a field group? I thought I might be able to use a relationship field but that only gets pages, posts, etc. (not values from populated ACF fields).

    Any help much appreciated.

  • Hi @friendofdog

    I’m afraid you can’t do it by using the relationship field. To do it, kindly check this guide: https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/. The guide is talking about the select field, but I believe you should be able to modify it for other fields too.

    I hope this helps 🙂

  • The second example was all I needed! Thanks, it works now. Here’s what I ended up using:

    function acf_load_color_field_choices( $field ) {
    
        $field['choices'] = array();
        
        $choices = get_field( 'colour_repeater', 'option', false );
    
        if( have_rows( 'colour_repeater', 'options' ) ): while ( have_rows( 'colour_repeater', 'options' ) ) : the_row();
    
            $choice = get_sub_field( 'colour_name', 'options' );
            $field['choices'][$choice] = $choice;
    
        $i++; endwhile; endif;
    
        return $field;
    
    }
    
    add_filter( 'acf/load_field/name=colours', 'acf_load_color_field_choices' );
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.