If you create a WordPress plugin, you want to allow users to change settings from the WordPress dashboard. Adding a WordPress admin menu lets you allow users to customize your plugin to fit their needs.

At this point in your WordPress plugin development, you should already have started to create the WordPress plugin function to control what your plugin does.

Create WordPress admin menu link

To make your WordPress plugin settings easily accessible, it's best to create an admin menu in the dashboard. This menu should have fields where users can customize your plugin to fit their exact needs.

Use the WordPress function add_action along with admin_menu to let WordPress know we're building an admin menu. Then pass the function name of your menu extra_post_info_menu that sets up your menu item.

add_action( 'admin_menu', 'extra_post_info_menu' );

function extra_post_info_menu(){

  $page_title = 'WordPress Extra Post Info';
  $menu_title = 'Extra Post Info';
  $capability = 'manage_options';
  $menu_slug  = 'extra-post-info';
  $function   = 'extra_post_info_page';
  $icon_url   = 'dashicons-media-code';
  $position   = 4;

  add_menu_page( $page_title,
                 $menu_title, 
                 $capability, 
                 $menu_slug, 
                 $function, 
                 $icon_url, 
                 $position );
}
Variable name Description
$page_title The title shown in the web-browser when viewing your plugin page
$menu_title The title for the menu button shown in the WordPress dashboard
$capability manage_options allows only Super Admin and Administrator to view plugin
$menu_slug URL to access plugin such as: /wp-admin/admin.php?page=extra-post-info
$function The function that contains the code for what to actually display on your plugin page
$icon_url Icon used in dashboard. You can use WordPress dash icons, or direct images like: $icon_url = plugins_url( 'extra-post-info/icon.png' );
$position Icon position in dashboard

WordPress position numbers:

2 Dashboard
 4 Separator
 5 Posts
 10 Media
 15 Links
 20 Pages
 25 Comments
 59 Separator
 60 Appearance
 65 Plugins
 70 Users
 75 Tools
 80 Settings
 99 Separator
Function name Description
add_menu_page The WordPress function that hooks in and builds our plugin menu in the dashboard

Blank plugin page accessed from dashboard menu

At this point you should be able to see your WordPress plugin menu in the dashboard. If you click on it, you're just going to get a blank page as you haven't told WordPress what to put here yet.

Create WordPress plugin page

Once your admin menu is made, the next thing you'll want to do is create a WordPress plugin page.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

0 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!