Back to Top

WordPress Custom Menu

Updated 12 September 2017

 

Default menu in wordpress are like Dashboard, Posts, Media, Comments, Plugins, etc. So, if we want to create a custom menu item of our own, we can can follow the following steps.

Code Snippet

add_action( "admin_menu", "custom_admin_menu" );

function custom_admin_menu(){

   add_menu_page(

    __( "Custom Menu", "text domain" ),

    __( "Custom Menu", "text domain" ),

    'manage_options', // access restriction

    'custom-menu', // menu slug

    'custom_menu_callback_function', // callback function

    'dashicon', // image

    25 // menu order

  );

  add_submenu_page(

    'custom-menu', // Parent menu slug

    __( "Custom Sub Menu", "text domain" ),

    __( "Custom Sub Menu", "text domain"),

    'manage_options', // access restriction

    'manage-submenu', // slug

    'custom_submenu_callback_function' // callback function

  );

}

function custom_menu_callback_function(){
  // html template for menu goes here...
}

function custom_submenu_callback_function(){
  // html template for submenu goes here...
}

Support

Still have any issue feel free to add a ticket and let us know your views to make the code better https://webkul.uvdesk.com/en/customer/create-ticket/

Thanks for Your Time! Have a Good Day!

Searching for an experienced
WordPress Company ?
Find out More
. . .

Leave a Comment

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


2 comments

  • Ryan Gosling
    • Webkul Support
  • 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