Support

Account

Home Forums ACF PRO Get_fields() / option page gives empty array

Solving

Get_fields() / option page gives empty array

  • Hi,

    I’ve setup a options page, now I’m trying to get the values of the option page with get_fields();

    if I vardump this it gives me an array with the correct key but with no value in it..
    array(2) { [“custom_field”]=> array(0) { } [“custom_field1”]=> bool(false)

    I’ve checked the database, the values get stored there.

    get_field(‘custom_field’, ‘option’);
    gives me NULL

    get_field(‘custom_field’);
    gives me an empty array: array(0) { }

    I’ve got no idea how to fix this.

  • Hi @floeske

    This is quite odd.

    Have you correctly saved the values on the options page.

    Kindly share with me some temporary login credentials to your site on a private ticket so that I may login and have a look at it.

    Hope to hear from you soon.

  • At the moment were quite busy developing the site.

    Database saving
    This is how it gets saved in the database, don’t know if its correct

  • Hi @floeske

    Could you please provide me the temporary admin credentials to the staging site so I can check the issue for you? You can set your reply visibility to “Private” if you want to share the credentials.

    Thanks!

  • Hello,

    I have the same issue, I try to get all the values from the options page but it only returns the keys + true/false, and not the complete array.

    example: $wds_settings = get_fields( 'options' );

    Array
    (
        [partners] => 5
        [favicon] => 
        [logo] => 68
        [copy] => © 2016
        [container] => container
        [default_text_color] => #58595b
        [default_font_size] => 14
        [default_text_line_height] => 16
        [h1_repeater] => 1
        [h3_repeater] => 1
        [h4_repeater] => 1
        [h5_repeater] => 1
        [h6_repeater] => 1
        [h2_repeater] => 1
        [main_menu] => 1
    )

    When the expected result is:

    Array
    (
        [partners] => Array
            (
                [0] => Array
                    (
                        [image] => 282
                        [option] => none
                        [link] => 
                        [download] => 
                    )
    
                [1] => Array
                    (
                        [image] => 279
                        [option] => none
                        [link] => 
                        [download] => 
                    )
    
                [2] => Array
                    (
                        [image] => 278
                        [option] => none
                        [link] => 
                        [download] => 
                    )
    
                [3] => Array
                    (
                        [image] => 281
                        [option] => pdf
                        [link] => 
                        [download] => http://somesite.com/wp-content/uploads/2016/03/iso.pdf
                    )
    
                [4] => Array
                    (
                        [image] => 286
                        [option] => pdf
                        [link] => 
                        [download] => http://somesite.com/wp-content/uploads/2016/03/inci.pdf
                    )
    
            )
    
        [favicon] => 
        [logo] => Array
            (
                [ID] => 68
                [id] => 68
                [title] => Wondercom
                [filename] => logo.png
                [url] => http://somesite.com/wp-content/uploads/2016/03/logo.png
                [alt] => 
                [author] => 1
                [description] => 
                [caption] => 
                [name] => logo
                [date] => 2016-03-16 13:56:00
                [modified] => 2016-03-16 13:56:06
                [mime_type] => image/png
                [type] => image
                [icon] => http://somesite.com/wp-includes/images/media/default.png
                [width] => 163
                [height] => 23
                [sizes] => Array
                    (
                        [thumbnail] => http://somesite.com/wp-content/uploads/2016/03/logo-150x23.png
                        [thumbnail-width] => 150
                        [thumbnail-height] => 23
                        [medium] => http://somesite.com/wp-content/uploads/2016/03/logo.png
                        [medium-width] => 163
                        [medium-height] => 23
                        [medium_large] => http://somesite.com/wp-content/uploads/2016/03/logo.png
                        [medium_large-width] => 163
                        [medium_large-height] => 23
                        [large] => http://somesite.com/wp-content/uploads/2016/03/logo.png
                        [large-width] => 163
                        [large-height] => 23
                    )
    
            )
    
        [copy] => © 2016 Wondercom.pt. Todos os Direitos Reservados
        [container] => container
        [default_text_color] => #58595b
        [default_font_size] => 14
        [default_text_line_height] => 16
        [h1_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 30
                        [line_height] => 35
                    )
    
            )
    
        [h3_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 22
                        [line_height] => 25
                    )
    
            )
    
        [h4_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 20
                        [line_height] => 23
                    )
    
            )
    
        [h5_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 18
                        [line_height] => 20
                    )
    
            )
    
        [h6_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 16
                        [line_height] => 18
                    )
    
            )
    
        [h2_repeater] => Array
            (
                [0] => Array
                    (
                        [text_color] => #58595b
                        [font_size] => 25
                        [line_height] => 30
                    )
    
            )
    
        [main_menu] => Array
            (
                [0] => Array
                    (
                        [geral] => 
                        [mainmenu_container] => container-fluid
                        [mainmenu_container_interior] => 1
                        [navbar_nav_right] => 
                        [search_bar] => 
                        [navbar_opt] => Array
                            (
                                [0] => Array
                                    (
                                        [border] => 0
                                        [border_radius] => 0
                                        [margin_bottom] => 0
                                        [min_height] => 50
                                        [border_style] => none
                                        [border_color] => transparent
                                        [position] => relative
                                    )
    
                            )
    
                        [multilang_support] => 
                        [cores] => 1
                        [colors] => Array
                            (
                                [0] => Array
                                    (
                                        [background_color] => 
                                        [border_color] => #ed9f4e
                                        [navbar_collapse_form_border] => #000000
                                        [navbar_text] => #ffffff
                                        [navbar_link] => #ffffff
                                        [navbar_link_hover] => #000000
                                        [navbar_brand] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [color] => 
                                                        [hover_focus_color] => 
                                                    )
    
                                            )
    
                                        [navbar_menu] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [color] => #ffffff
                                                        [dropdown_menu] => 
                                                        [hover_focus_color] => #000000
                                                        [color_active] => #000000
                                                        [color_active_bg] => 
                                                        [color_open] => 
                                                        [color_open_bg] => 
                                                    )
    
                                            )
    
                                        [navbar_toggle] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [border_color] => 
                                                        [hover_focus_color] => 
                                                        [icon_bar_bacground] => 
                                                    )
    
                                            )
    
                                    )
    
                            )
    
                    )
    
            )
    
    )

    Also in order to the above array show I have to do this:

    while ( has_sub_field( 'main_menu', 'option' ) ):
    endwhile;
    $settings = get_fields( 'options' );
  • Hi @drosendo

    I’m afraid that I couldn’t reproduce this issue on my end. It’s possible that your site has a function that modifies the returned values. To make sure, could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    Also, could please make sure that you have the latest version of ACF and WordPress?

    If the issue persists, could you please open a new ticket here: https://support.advancedcustomfields.com/new-ticket/, explain the issue again and provide temporary admin credentials in the ticket?

    Thanks!

  • I have submited the ticket.

  • Hi,

    Still waiting on response from open ticket.

    Thanks,
    David

  • Hi @drosendo

    I’m afraid I couldn’t find a ticket with your issue in our system. Could you please submit it again? I’m sorry for the inconvenience.

    Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Get_fields() / option page gives empty array’ is closed to new replies.