How to add Custom admin Menu to Wordpress

Here We will get the way of adding Custom admin menu.



The Wordpress Back end Admin already Has Menus  like Pages, Post, Appereance etc...

How can we add a new menu at there..?? So, We can add a menu by just adding a few lines of code in function.php

Function.php file is located in your theme folder eg. wp-content/themes/my_theme/functions.php

Add Following Code in Function.php   


add_action('admin_menu', 'register_custom_menu_page');

function register_custom_menu_page() {
   add_menu_page('custom menu title', 'custom menu', 'add_users', 'myplugin/myplugin-index.php', '',   plugins_url('myplugin/images/icon.png'), 6);
}


After adding this code you can see a new menu in wordpress admin panel.

Here Custom menu is Title or Label of the Menu. and the myplugin/myplugin-index.php is the link when we are click on the menu custom menu the Page navigate to the myplugin-index.php

Example

You can also linked your page Here For Example you are created a code page in wp-admin/customcontent.php  So it will be..

add_action('admin_menu', 'register_custom_menu_page');

function register_custom_menu_page() {
   add_menu_page('custom menu title', 'custom content Type', 'add_users', 'wp-admin/customcontent.php', '',   plugins_url('myplugin/images/icon.png'), 6);
}

Comments