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?
Jacek
December 9, 2020, 7:20pm
2
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… Any other ideas?
Jacek
December 9, 2020, 9:55pm
4
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!
folbert
December 10, 2020, 6:14am
7
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…
system
Closed
January 20, 2021, 6:07pm
9
This topic was automatically closed after 42 days. New replies are no longer allowed.