Tutorials, Wordpress

How to add custom menu pages in wordpress admin?

26 February 2019

In this blog, we will learn how to add custom menu pages with sub-menu page in wordpress admin sidebar.

we will use add_menu_page() & add_submenu_page() function for achieve this functionality.


add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = ”, string $icon_url = ”, int $position = null )

Add a menu page.


add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = ” )

Add a sub-menu page.


add_action( 'admin_menu', 'codecanal_admin_menu' );

function codecanal_admin_menu() {
	add_menu_page( 'My Top Level Menu Example', 'Top Level Menu', 'manage_options', 'top-menu', 'codecanal_admin_page', 'dashicons-tickets', 6  );
        add_submenu_page( 'top-menu', 'My Sub Level Menu', 'Sub Level Menu', 'manage_options', 'top-sub-menu', 'codecanal_admin_sub_page' );

function codecanal_admin_page(){?>	
 <div class="wrap">		
   <h2>Welcome To Top Level Menu</h2>

function codecanal_admin_sub_page(){ ?>	
 <div class="wrap">		
  <h2>Welcome To Sub Level Menu</h2>



Leave a Comments