Sage 9, ACF Options page not appear

Hi guys, im working on Sage 9 with ACF PRO and i want to make theme options page but it’s not working.

Here is my code:

<?php

namespace App;

if(function_exists('acf_add_options_page') ) {
acf_add_options_page();
}

Its looks like there is no ‘acf_add_options_page’ function when i debug with echo

Can you help me?

Try with add your code to setup.php and init anonymous function

add_action('init', function() {

 // your code
 if(function_exists('acf_add_options_page') ) {
  acf_add_options_page([
    page_title => 'Title page',
    // other settings
  ]);
 }

});

Link to ACF documentation with ACF options page settings
https://www.advancedcustomfields.com/resources/acf_add_options_page/

Still nothing… :frowning: Any other ideas?

After add below action you should have option page in acf

setup.php

add_action('init', function () {
    
    if (!function_exists('acf_add_options_page')) {
        return;
    }
    acf_add_options_page([
        'page_title'    => 'Example Settings',
        'menu_title'    => 'Example Settings',
        'menu_slug'     => 'examplesettings',
        'capability'    => 'edit_posts',
        'parent_slug'   => '',
        'position'      => 2, 
        'icon_url'      => 'dashicons-admin-generic'
    ]);
});

I know but it’s still not working. When i remove if statement there is error:
Fatal error: Uncaught Error: Call to undefined function App\acf_add_options_page()

Ok, i got it! Thanks for help!

I assume this was a namespace issue but it might be helpful to anyone coming here in the future if you describe what the solution was.

I reinstalled ACF PRO and it started to work…

This topic was automatically closed after 42 days. New replies are no longer allowed.