How to add admin menu in WordPress

Below is the step-by-step guide to help you create an admin menu:

1. Register admin menu:

Add the following code to your plugin file or functions.php to register a new menu page:

    add_action('admin_menu', 'esparks_admin_menu');
function esparks_admin_menu() {
    add_menu_page(
        'Esparks Page',   
        'Esparks',    
        'manage_options',   
        'e-sparks',  
        'esparks_menu_callback_function'
    );
  }

Here, Esparks Page is the title of admin page to be created,

Esparks is the Title of admin menu,

manage_options is the capability required to access the menu page,

e-sparks is the slug of menu page and,

esparks_menu_callback_function  is the function which would be called on clicking the menu.

For example:

     function esparks_menu_callback_function() {
    echo 'Admin Menu';
}

The admin menu will be added.