Contents
The add_menu_page and add_submenu_page functions are used to add menu and submenu items to our WordPress dashboard. For example, in the screen-shot below, we have added a new Shiba Themes menu. It contains the submenus Shiba Themes, Add New, and Theme Options. Add a new custom post type submenu.
Page title – Title of the page or screen that the submenu links to. If you are rendering your own page, then the page title value is stored in the global $title. Menu title – Title of the submenu. Capability – Defines what permissions a user must have in order to access this submenu.
How to add CPT admin menu as sub menu?
The args for page title, menu title, caps, etc above need to match your register CPT args. Or you can make it pull data from your registered CPT object to make it easier: * Add admin menu. The code above will add CPT link under “Media” menu.
How to display current parent and its sub menu only?
Then you can display it in your theme using wp_nav_menu (just like you normally would), but also passing in a sub_menu flag to activate the custom sub_menu function: When on a page you first get all the pages, then you can get the current page ID, get the children in an array and loop through this array like this:
When I change add_submenu_page () to add_options_page (), it correctly shows a new link under the Settings menu, but it doesn’t show under the Portfolios menu. What am I doing wrong?
The hook you should use is admin_menu. For $menu_slug please don’t use __FILE__ it makes for an ugly URL, and is a minor security nuisance. Within the rendering function $function you may want to access parameters you used in add_submenu_page (), such as the $page_title.
How to add a new menu page in Photoshop?
My New Menu Page!! Add a new menu page with add_menu_page. Page title – Title of the page or screen that the menu links to. If you are rendering your own page, then the page title value is stored in the global $title. Menu title – Title of the menu. Capability – Defines what permissions a user must have in order to access this menu.