Scotts Web Dev Banner
Did you notice... every article on this site has an associated video? Consider subscribing to Scotts Web Dev on YouTube! :)

How To Add A Menu Page To WordPress Admin Area

In this video, I show you how to create a new menu page in the WordPress admin area. This will create a new menu item on the left hand side menu when you log into the backend.

Place this code in functions.php (of a child theme if your theme can be updated) or another globally accessible file. If you’re editing someone elses theme please see my video about creating a wordpress child theme.

The Code For Adding A Menu Page In WordPress

This is just a sample code that creates a menu page called Say Hello and outputs a simple message to the screen. We will break it down after.

add_menu_page(
    'Say Hello',
    'Say Hello',
    'read',
    'say-hello',
    'do_say_hello',
    'dashicons-format-chat',
    999
);

function do_say_hello() {
    ?>
    <div class="wrap">
        <h1>Say Hello</h1>
        <p>I just wanted to say hello to you on your new admin page!</p>
    </div>
    <?php
}

The function is called add_menu_page() and it has 6 parameters

  1. Page Title – The title of the new page
  2. Menu Title – The menu item text
  3. Capabilities – This determines who can access the newly created page (see wordpress roles and capabilities page). ‘read’ is for everyone, while something like ‘update_plugins’ would be only for administrators.
  4. Slug – This is the slug that shows in the url of the newly created page
  5. Callback Function – This is the callback function that gets executed when the page is accessed
  6. Icon – This is the image that shows next to the menu item (see dashicons page)
  7. Position – This is the number that determines where your menu page sits in the menu