Home › Forums › Add-ons › Options Page › Adding submenu pages › Reply To: Adding submenu pages
Well… I tried lots of different things. For example, the following got the menus in the right place, but no fields got added to the options page (the only rule option I have is Options Page = Site Options).
public function add_site_options()
{
//add section heading
$page_title = 'Site Tools';
$menu_title = 'Site Tools';
$capability = 'manage_options';
$menu_slug = 'site_options_tools';
$function = array( $this, 'site_options_tools_html' );
$icon_url = NULL;
$position = 500;
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
//add general site options menu
$parent_slug = 'site_options_tools';
$page_title = 'Site Tools';
$menu_title = 'Site Tools';
$capability = 'manage_options';
$menu_slug = 'site_options_tools';
$function = array( $this, 'site_options_tools_html' );
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
}
public function acf_options_setup()
{
if( function_exists('acf_set_options_page_menu') )
{
acf_set_options_page_menu( 'Site Options' );
}
if( function_exists('acf_add_options_sub_page') )
{
acf_add_options_sub_page(array(
'menu' => 'Site Options',
'title' => 'Site Options',
'slug' => 'acf_site_options',
'parent' => 'site_options_tools',
'capability' => 'manage_options'
));
}
}
//in __construct()
$this->add_action( 'plugins_loaded', 'acf_options_setup' );
$this->add_action( 'admin_menu', 'add_site_options' );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.