In this brief wordpress tutorial I`ll show you how to add menu and sub-menu items to wordpress backend admin(wp-admin).
In order to add your menu items you`ll use add_menu_page and add_submenu_page functions. They`re very well documented in the WordPress Codex so I won`t get into much detail there.
add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function )
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position )
//Hook your function to "admin_menu" action add_action('admin_menu', 'qa'); function qa() { //Add your menu pages and subpages add_menu_page(__('Toplevel Q&A','qa-menu'), __('Q&A Management','qa-menu'), 'manage_options', 'qa-management', 'qa_functionality' ); add_submenu_page( 'qa-management', 'Add', 'Add', 'manage_options', 'qa-add', 'add_functionality' ); add_submenu_page( 'qa-management', 'Order', 'Order', 'manage_options', 'qa-order', 'order_functionality' ); } //Functions for your menu pages function qa_functionality() {/* Function for your Main menu item*/ } function add_functionality() {/*Function for "Add" menu item*/} order_functionality() {/*Function for "Order menu item"*/}
And that is it. Now the only thing left for you to do is design the functions for your menu items. There is nothing difficult in designing them just approach each one like a separate php file that serves for your menu items.Pretty standart…try
function qa_functionality() {echo '<h1>First menu page</h1>'; }
You can use this either in functions.php of your theme or your plugin.
There you have it you created your plugin/theme backend menu in just a few minutes.