CorePlugin Development

How to add menu in wordpress admin dashboard

By December 9, 2018 No Comments

Create a Menu in WordPress admin panel

In this post we see how we can add custom menu to admin sidebar. Sometimes when we work with plugins or theme and we need to show some features or any information in admin page then we can use this code snippet to create the same.

As we know WordPress provide hook using which we can easily add custom admin menu. So, for this we’ll use ‘admin_menu’ hook and add action to this hook

1. Creating menu –

Add this code in functions.php file of your plugin or theme.

add_action('admin_menu', 'custom_menu');

In above line of code, first parameter is the hook we discuss about, Second parameter is name of callback function. In callback function you have to write what you want to alter in admin menu.

function custom_menu() { 
      'Page Title', 
      'Menu Title', 


As you can see in custom_menu() function I just used add_menu_page(). This function allow you to create a menu in admin sidebar and map that menu to a page.

In custom_menu() function

  • First parameter is page title. the title tag of the page when the menu is selected..
  • Second parameter is menu title. The text to be used for menu title.
  • Third one is capability, The capability required for this menu to be displayed to the user. You can find a list of all WordPress capabilities here –
  • Fourth parameter is menu slug, which is used for creating page URL. Keep this unique.
  • Fifth parameter is page callback function. The function to be called to output the content for this page.
  • Sixth parameter is for icon, either you can provide a URL of image or you can choose predefined WordPress icons.

Content Credit:

Leave a Reply