Support

Account

Home Forums ACF PRO Retrieve value from a specific options page Reply To: Retrieve value from a specific options page

  • Hi @matekk , contrary to what is said in https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/, is it possibile with the ACF Api.

    We create for example a “Page A” in this way:

    $page_a = array(
                    'page_title' => 'Page A',
                    'menu_title' => 'Page A',
    		'post_id' => 'page_a'
    		);
    acf_add_options_page($page_a);
    
    

    And a “Option” page in this similar way:

    $option = array(
    		'page_title' => 'Option',
                    'menu_title' => 'Option',
    		'post_id' => 'option'
    		);
    acf_add_options_page($option);
    

    Now you create a new Field Group with an “images” field and make this field visible when “Page Options” = “Page A” and similarly you create a new Field Group with an “images” field (it can also be a clone of the previous “images” field but watch out that the clone field name is something like “clone-images”) and make this field visible when “Page Options” = “Option”.

    Now you can get the “images” field from “Page A” page with:

    the field("images", "page_a")

    and the “images” field from “Option” page with:

    the field("images", "option")

    because in Wp DB (‘wp_options’ page) the “images” field from “Page A” is saved as option_name ‘page_a_images” and the “images” field from “Option” page is saved as “option_images”.