Support

Account

Home Forums Front-end Issues Display ACF fields that are modified by filters Reply To: Display ACF fields that are modified by filters

  • $field = get_field_object( 'custom_field' );
    echo '<pre>'; print_r($field['choices']); echo '</pre>';
    //Displays
    Array
    (
        [ID] => 177
        [key] => field_5dcf111592fe2
        [label] => Custom Color
        [name] => custom_field
        [prefix] => acf
        [type] => select
        [value] => blue
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => Array
            (
                [0] => Array
                    (
                        [0] => Array
                            (
                                [field] => field_5dcf0ad861cf1
                                [operator] => ==
                                [value] => background
                            )
    
                    )
    
            )
    
        [parent] => 176
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [choices] => Array
            (
               [Blue] => Blue
               [Red] => Red
               [Green] => Green
               [Yellow] => Yellow
               [White] => White
               [Pink] => Pink
            )
    
        [default_value] => Array
            (
            )
    
        [allow_null] => 1
        [multiple] => 0
        [ui] => 0
        [return_format] => value
        [ajax] => 0
        [placeholder] => 
        [_name] => background
        [_valid] => 1
    )
    $value = get_post_meta( $post_id, 'custom_field', true );
    echo $value;
    //Displays
    blue

    I see the intended choices when I go into edit the custom fields. The select menu shows me:

    blue : Blue
    red : Red
    green : Green
    yellow : Yellow
    white : White
    pink : Pink