Hi all
I’ve just recently installed ACF PRO on a new site and am running into an issue with the Options feature (née add-on). I’ve added the v5.x code to add in Options pages into my functions.php
, the Options page shows up, but when adding a new Custom Field Group, it says “No options pages exist”.
Here’s the code I’m using:
function lb_add_option_menus() {
if (function_exists('acf_add_options_page')) {
acf_add_options_page();
acf_add_options_sub_page('Page 1');
acf_add_options_sub_page('Page 2');
}
}
And here’s the action add_action('admin_menu', 'lb_add_option_menus', 98);
I’ve tried deactivating/reactivating ACF PRO, changing the priority for the admin_menu
action, and read through a number of support threads on this site, but can’t seem to rectify the issue. If anyone has a fix, I’d love to see it!
Basic details
WordPress Version: 3.9.2
ACF PRO Version: 5.0.2
PHP Version: 5.5.10
Cheers!
Try this instead:
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Options',
'menu_title' => 'Options',
'menu_slug' => 'options',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Page 1',
'menu_title' => 'Page 1',
'parent_slug' => 'options',
));
acf_add_options_sub_page(array(
'page_title' => 'Page 2',
'menu_title' => 'Page 2',
'parent_slug' => 'options',
));
}
Not need for an action hook.
Source: http://www.advancedcustomfields.com/resources/acf_add_options_page/
Thanks Etic, that worked! I thought you had to wrap it in a function along with an add_action
hook, but I guess not.