Posts

Showing posts with the label Add Submenu Page

Wordpress - Add An Admin Page, But Don't Show It On The Admin Menu

Answer : From the docs on add_submenu_page() , you see that you can hide your submenu link from a top level menu item to which it belongs be setting the slug (1st argument) to null : add_action( 'admin_menu', 'register_my_custom_submenu_page' ); function register_my_custom_submenu_page() { add_submenu_page( null, 'My Custom Submenu Page', 'My Custom Submenu Page', 'manage_options', 'my-custom-submenu-page', 'my_custom_submenu_page_callback', ); } To highlight the desired menu item (e.g. 'all charts' when accessing the hidden 'edit chart' page), you can do the following: add_filter( 'submenu_file', function($submenu_file){ $screen = get_current_screen(); if($screen->id === 'id-of-page-to-hide'){ $submenu_file = 'id-of-page-to-higlight'; } return $submenu_file; }); Use a submenu page as parent slug...