In my admin sidebar I want the ‘Header’ sub-page to show under the ‘TEST’ parent, but it still shows up under the default ‘Options’ menu in the side bar. And the ‘TEST’ link doesn’t have a sub-page. What am I doing wrong?
if( function_exists('acf_add_options_page') ) {
acf_add_options_page('TEST');
acf_add_options_sub_page('Header');
acf_add_options_sub_page('Footer');
acf_add_options_sub_page('Accommodation');
$acf_add_options_page = (array(
'page_title' => 'TEST',
'menu_title' => 'TEST',
'menu_slug' => 'theme-options',
'capability' => 'edit_posts',
'position' => false,
'parent_slug' => '',
'icon_url' => false,
'redirect' => false
));
$acf_add_options_sub_page = (array(
'page_title' => 'Header',
'menu_title' => 'Header',
'menu_slug' => 'theme-options-header',
'capability' => 'edit_posts',
'position' => false,
'parent_slug' => 'theme-options',
'icon_url' => false,
'redirect' => false,
));
}
Try this:
if (function_exists('acf_add_options_page')) {
//Create the parent.
$parent = acf_add_options_page(array(
'page_title' => 'TEST',
'menu_title' => 'TEST',
'redirect' => false
));
//Create the children.
acf_add_options_sub_page(array(
'page_title' => 'Header',
'menu_title' => 'Header',
'parent_slug' => $parent['menu_slug'],
));
acf_add_options_sub_page(array(
'page_title' => 'Footer',
'menu_title' => 'Footer',
'parent_slug' => $parent['menu_slug'],
));
acf_add_options_sub_page(array(
'page_title' => 'Accommodation',
'menu_title' => 'Accommodation',
'parent_slug' => $parent['menu_slug'],
));
}
I found this on the documentation, see the bottom example “Custom options sub page”: https://www.advancedcustomfields.com/resources/acf_add_options_sub_page/
Perfect, thank you for your help