create an admin page

How to create an admin page for your WordPress plugin

This post has been viewed 193 times.

In this tutorial, we are going to create an admin page for your WordPress plugin.

If you are using some famous plugins such as Yoast SEO, you can see that they have their own admin menu page that can be seen in the WordPress sidebar menu.

What you’ll need:

  • Clean installation of WordPress.
  • Basic knowledge of WordPress plugins.
  • Basic knowledge of WordPress hooks.

Step 1: Create a plugin file.

We will create a file named as admin.php and the content as follows:

Step 2: Create a function.

The content of this function will be displayed when we visit the admin page of our plugin.

Step 3: Add an action hook.

Since we are going to add an admin menu to our plugin, we have used the admin_menu in the first parameter.

This hook will allow WordPress to process a specific action. The specific function that I am talking about will be tackled next step.

Step 4: Call the add_menu_page function.

The text My Plugin will be the name of our menu. adminPageContent is the name of the function that we have declared in Step 2. dashicons-wordpress will be the icon for our menu. You can select for more here.

Complete code:

That’s it, just simply activate the plugin that we have created and it must add a menu in the sidebar with a WordPress logo as the icon and My Plugin as the menu title.

Hello, I am a freelance website and mobile application developer. I am also the owner of this website, so if you have any projects for me you can contact me at [email protected] or use the contact page. When I’m not doing some work, I can be found watching Anime/Asian Dramas/American TV Series, playing computer games, and writing tutorials on this website. I run the program repeatedly hoping the error won’t show up next time.