Hướng dẫn thêm add menu trong WordPress admin panel

Written by admin
Posted on Tue, 08/10/2021 - 05:23

Share Everywhere

Table of contents

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 – https://codex.wordpress.org/Roles_and_Capabilities
  • 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. https://developer.wordpress.org/resource/dashicons/

Reference – https://themes.artbees.net/blog/wordpress-custom-admin-pages/

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Câu nói tâm đắc: “Điều tuyệt với nhất trong cuộc sống là làm được những việc mà người khác tin là không thể!”