Home Forums ACF PRO Can't Register Options Page from Plugin


Can't Register Options Page from Plugin

  • Hey, I’m attempting to register an options page from a custom plugin but for some reason the page won’t register. If I put the same code in my theme file, the options page registers fine. All the other functions in the plugin work fine. But for some reason this doesn’t:

    if( function_exists(‘acf_add_options_page’) ) {

    $page = acf_add_options_page(array(
    ‘page_title’ => ‘Theme General Settings’,
    ‘menu_title’ => ‘Theme Settings’,
    ‘menu_slug’ => ‘theme-general-settings’,
    ‘capability’ => ‘edit_posts’,
    ‘redirect’ => false


    In fact, if I remove the “if function exists” wrapper, I get “Fatal error: Call to undefined function acf_add_options_page() “.

    Any idea what’s going on? I’ve registered options like this dozens of times, but for some reason it’s not working today.

  • I figured it out. Plugins load in alphabetical order. My plugin had “45” in its name, so it was loading before ACF. I renamed it “Forty-five” and problem solved.

    More info here:

  • I know that you marked this as a solution, but I wanted to post this for others that find it. You can’t be sure of the order that plugins are loaded unless you activate them in a specific order. Updating a plugin usually causes it to deactivate and reactivate, changing the order of the array mentioned in the link you gave.

    It’s better to run a function on a WP hook, for example

    add_action('init', 'my_init_function');
    function my_init_function() {
        if (function_exists('acf_add_options_page')) {
            $page = acf_add_options_page(array(
                'menu_title' => 'Theme Settings',
                'menu_slug' => 'theme-general-settings',
                'capability' => 'edit_posts',
                'redirect' => false

    the plugins_loaded hook would also work in this case

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

The topic ‘Can't Register Options Page from Plugin’ is closed to new replies.