$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>admin menu: use default "general" page for theme settings using add_menu_page and add_submenu_page|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

admin menu: use default "general" page for theme settings using add_menu_page and add_submenu_page

matteradmin9PV0评论

How can I make my theme settings admin menu showing "general" as default page while keeping its menu title as "theme settings"?

I mean at the moment I got this using add_menu_page and add_submenu_page:

But I want to have "general"... I am struggling to figure this out... Is it not possible?

How can I make my theme settings admin menu showing "general" as default page while keeping its menu title as "theme settings"?

I mean at the moment I got this using add_menu_page and add_submenu_page:

But I want to have "general"... I am struggling to figure this out... Is it not possible?

Share Improve this question edited Jan 15, 2018 at 22:35 neoDev asked Jan 15, 2018 at 22:30 neoDevneoDev 1159 bronze badges 4
  • Have a look at [this] (wordpress.stackexchange/a/65822/134934) , Some guy used hooks on wp-admin.php to redirect to desired page – Maor Harush Commented Jan 15, 2018 at 22:50
  • I am not sure how doing this I would be able to change the title to "general", and without get duplicated pages... – neoDev Commented Jan 15, 2018 at 23:00
  • So when someone clicks on the "Theme settings" (with the cog icon) you want them to be on "General" page - where the red arrow points on your image? – Greg36 Commented Jan 16, 2018 at 2:10
  • @Greg36 yes. This is what I am trying to have. – neoDev Commented Jan 16, 2018 at 14:52
Add a comment  | 

1 Answer 1

Reset to default 0

You need to create a submenu page with the same slug as the menu page. E.g.

$menu_slug = "my_menu_slug";
$desired_capability = "manage_options"; //Or whatever you need
$menu_page_callback = "menu_page_callback_function";

add_menu_page(
    "Page Title", 
    "Menu Title", 
    $desired_capability, 
    $menu_slug, 
    $menu_page_callback
);

add_submenu_page(
    $menu_slug, 
    "Submenu Page Title", 
    "Submenu Menu Title",
    $desired_capability, 
    $menu_slug, 
    $menu_page_callback
);
//Note, the 5th and 6th parameters here are the same as above. This 
//overrides the first submenu title. Now clicking the 
//menu title and the first submenu item will navigate to the same page, 
//generated by the menu_page_callback function.
Post a comment

comment list (0)

  1. No comments so far