Home Forums Add-ons Options Page Can't get value of custom Options page


Can't get value of custom Options page

  • Guys, I’m struggling with problem about getting values from option pages. I’ve created two Option pages in functions.php

    $languages = array( 'en', 'de' );
        foreach ( $languages as $lang ) {
            acf_add_options_page( array(
                'page_title' => 'Site Options (' . strtoupper( $lang ) . ')',
                'menu_title' => __('Site Options (' . strtoupper( $lang ) . ')', 'text-domain'),
                'menu_slug'  => "site-options-${lang}",
                'post_id'    => "options_${lang}"
            ) );

    This works fine, I’ve created fields for both options pages but I can’t get any value with following code:
    print_r(get_field( 'announcement', 'options_en' ));
    I can’t get value from any Option page if “post_id” is not “options”.
    Have someone faced same problem?

  • May I ask how you solved this? Having the same issue. I can retrieve basic text fields but Post Object fields I can’t retrieve.

  • @mitchellau you should probably start a new topic. I doubt that your problem and the OP’s are the same. My suspicion is that the OP’s issue was here

    'menu_slug'  => "site-options-${lang}",
    'post_id'    => "options_${lang}"

    should be

    'menu_slug'  => "site-options-{$lang}",
    'post_id'    => "options_{$lang}"
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.