Support

Account

Home Forums Backend Issues (wp-admin) Cannot create Site Options page

Solving

Cannot create Site Options page

  • Hello. I am unable to create a Site Options page using the provided sample in the documentation. I have read 4 or 5 other posts on this forum concerning this issue and none of the solutions have helped.

    The odd thing is, the below code in functions.php seems to work locally. But when I deploy my code to Pantheon, it is not working. Anyone ever have an issue like this?

    ACF Pro 5.8.7
    WordPress 5.3.2
    Pantheon Performance Small

    functions.php

    if(function_exists('acf_add_options_page')) {
        $option_page = acf_add_options_page(array(
            'page_title' => 'Site Options',
            'menu_title' => 'Site Options',
            'menu_slug' => 'site-options',
            'capability' => 'manage_options',
            'redirect' => false
        ));
    }
  • Not sure where to start with your problem, but remember that options pages have two components.

    #1 the code above creates a placeholder page

    #2 You have to create a field group and choose to display it on this page

    Your fields have to exist on the same wordpress installation as that options page code. Either make sure they are setup in the UI, or export them to php and add them to your functions.php

  • It could be that on the other server that the function function_exists() does not exist when you code is running. It’s unlikely but possible.

    Try adding a test on the server where you’re having the issue

    
    if(function_exists('acf_add_options_page')) {
        $option_page = acf_add_options_page(array(
            'page_title' => 'Site Options',
            'menu_title' => 'Site Options',
            'menu_slug' => 'site-options',
            'capability' => 'manage_options',
            'redirect' => false
        ));
    } else {
      // report that function does not exist
      die('function acf_add_options_page does not exist');
    }
    
  • I was able to get this working eventually. Thank you both for the replies. This actually seems to have been something related to my child theme I am using (that is my guess). I switched to a different theme and then switched back to my child theme and the options page was added to the menu. So I’m guessing something in that process (disabling/enabling) finally made this code run?

    Thanks.

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

You must be logged in to reply to this topic.