Reading list Switch to dark mode

    How to add menu in WordPress admin panel

    Updated 18 September 2023

    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() { 
    
      add_menu_page( 
          'Page Title', 
          'Menu Title', 
          'edit_posts', 
          'menu_slug', 
          'page_callback_function', 
          'dashicons-media-spreadsheet' 
    
         );
    }

    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.

    Searching for an experienced
    WordPress Company ?
    Find out More

    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/

    Wordpress Dashboard

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

    Support

    Still have any issues feel free to add a ticket and let us know your views to make the code better create a ticket.

    Thanks for Your Time! Have a Good Day! Also, Hire WooCommerce Developers for all kinds of services for web and mobile development, plugin development, mobile app, design services, and much more.

    If you need custom WordPress Development services then feel free to reach us and also explore our exclusive range of WordPress WooCommerce Extensions.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    16 comments

  • Felicia Mcbride
  • phptechie
    • Zeba Hakim (Moderator)
  • Sonu kumar
    • Sagar Bansal (Moderator)
  • sagar sharma
    • Mohit Verma (Moderator)
  • Nasiruddin Khan
    • Mohit Verma (Moderator)
  • Eren
  • Ben
    • Mohit Verma (Moderator)
  • pradeep
    • Mohit Verma (Moderator)
      • Coto
        • Mohit Verma (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content