how to add menu in wordpress admin panel

Code for adding a custom page in the WordPress Admin section. In this process, only three steps required.

Step-1 :- Show page in admin section

function mt_toplevel_page() 
{
    echo '<a href="your-page-name.php"><h3>Your menu name in admin</h3></a>';
    require_once( get_theme_root() . '/ your-page-name.php' );
}

 

Step-2 :- Add and Show menu name in admin section.

// Hook for adding admin menus
add_action('admin_menu', 'mt_add_pages_1');
// action function for above hook
function mt_add_pages_1()
{
    // Add a new top-level menu (ill-advised):
    add_menu_page(__(' Your menu name in admin,'menu-test'), __(' Your menu name in admin ','menu-test'), 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' );
}

 

Leave a Reply