Create plugin in WordPress

Create plugin in WordPress step by step tutorial for beginners

This tutorial will guide you on how to create plugin in WordPress.

WordPress plugins are simply PHP scripts that extend the functionality of your WordPress website. If you have a running WordPress website and you need to add some functionality you can always rely on the wordpress plugin directory, this enables you to add functionality to your website without the need to learn on how to code.

But, what if the functionality that you are looking for is not available? If you are a developer, then you need to write the code yourself and if you are generous enough you will make the plugin flexible, meaning it can be installed and it is compatible with all WordPress websites. If you are non-developer then you might need to hire a developer to do it for you or instead search for an alternative plugin that suits your needs.

Step 1: Create a folder.

You will need to create a folder with the folder name as your plugin name. Then put this folder in the wp-content/plugins directory.

In this tutorial, we will name the folder as mysuperbplugin.

Step 2: Create a PHP file.

The PHP file must be inside the folder that you have created and for this tutorial, we will name it as mysuperbplugin.php.

The content of mysuperbplugin.php is as follows:

Plugin Name: My Superb Plugin
Plugin URI:
Description: A very superb plugin.
Version: 1.0.0
Author: David Angulo
Author URI:
License: GPL2

The content above will be the description of your plugin. This is a standard format and you can add more information if you want.

If you navigate to your plugins, you should see My Superb Plugin in the list. You might want to activate your plugin now even though it does not have any function just yet.

Step 3: Plan your plugin functionality.

Ask yourself, what should your plugin do? There are tons of plugins in the WordPress directory and if you are planning to include yours in that list you must create something unique.

Plugins can be a simple such as printing a text to complex such as having an e-commerce plugin or reservation plugin. Each plugin has their own functionalities.

I will just list some functionalities and example plugins that can guide you on how to create plugin in WordPress.

a. Admin Page

create an admin page
a. An admin page.

Most of the big plugins use this functionality. Since their plugins offer a wide range of options and configurations they will need to create a user interface for users to easily use their plugin.

A plugin that uses an Admin Page is Simple Author Box.

(Read: How to create an admin page for your WordPress plugin)

b. Sub-menu Page

b. A sub-menu page.

If one page is not enough then you need to add more pages for your plugin. This will add a child menu on the Admin page.

A plugin that uses Sub-menu Page is Yoast SEO.

(Read: How to add submenu in WordPress custom plugin)

c. Settings Page

How to create a settings page for your WordPress plugin
c. A settings page.

Some plugin needs to be configured to the settings to let the users pick the functions that they want to enable and disable. The settings page allows your plugin to save settings in the WordPress that you can use.

A plugin that uses Settings Page is WP Mail SMTP.

(Read: How to create a settings page for your WordPress plugin)

d. Dashboard Widget

How to create a dashboard widget in WordPress
d. A dashboard widget.

Dashboard widgets are the content that you see in WordPress admin dashboard. This is the first page that an admin will see whenever he login. This is a good functionality used for a summary of reports.

A plugin that uses Dashboard Widget is Wordfence.

(Read: How to create a dashboard widget in WordPress)

e. Shortcode

e. A login form shortcode.

A shortcode is a text that you can use in WordPress WYSIWYG editor to show some functionality. An example is when you have created a form using HTML, you can register it using the shortcode and this shortcode will be used in the editor for the form that you have created to appear.

A plugin that uses Shortcode is Separate Login Form.

(Read: How to create custom WordPress shortcode plugin from scratch)

f. Upload Files

upload files in WordPress programmatically
f. A file uploader plugin.

If you are developing a plugin that needs to upload files then you can use this functionality. All files uploaded using this uploader will be uploaded to wp-content/uploads directory.

(Read: How to upload files in WordPress programmatically)

h. Posts Custom Column

How to add custom column in WordPress post
h. A custom last modified date column.

Whenever you navigate to All Posts, you can see the list in a table. If you are developing a plugin that is specific for posts, then you can add a custom column generated by your plugin. Maybe you want to create a plugin that allows users to rate each post and the summary will be listed in the custom column.

A plugin that uses Posts Custom Column is Posts Unique View Counter.

(Read: How to add custom column in WordPress post)

i. Custom Database Tables

Sometimes, your plugin just needs a database to store its data. This will allow your plugin to automatically creates database tables when activated where the tables you have created can be used to perform database operations.

A plugin that uses Custom Database Tables is Caldera Forms.

(Read: How to create database tables when your plugin is activated)

j. Cron Jobs

Cron jobs are actions that are automatically executed every a specific interval. If you are creating that needs to do something automatically then you this functionality will fit your plugin.

The WordPress itself uses cron jobs.

A plugin that uses Cron Jobs is WP Crontrol.

(Read: How to create  cron job in WordPress)

So have you got any idea of what your plugin needs to do? You can always refer to look for a non-existent plugin and create them or innovate some plugins that need have additional functionalities.

Here are some plugins that have a step by step tutorial for beginners.

a. CRUD Operations Plugin (Step by Step tutorial)

This is a simple plugin that can do crud(create/read/update/delete) operations. You can refer to this tutorial to have a better understanding of WordPress database operations.

(Read: How to create CRUD operations plugin in WordPress)

b. Contact Form Plugin (Step by Step tutorial)

This is a simple plugin that allows you to put a contact form on any page/post that you want and this tutorial will guide you on how to create it.

(Read: How to create a contact form plugin in WordPress)

Step 4: Upload your plugin.

If you have successfully created your own plugin, then it is time to upload it to the WordPress plugin directory. This will allow your plugin to be open for use in public.

(Read: How to upload your plugin to WordPress plugin directory)

That’s it, I hope you are able to create plugin in WordPress.

how to upload your plugin to WordPress plugin directory

How to upload your plugin to WordPress plugin directory

In this tutorial, I will guide you on how to upload your plugin to WordPress plugin directory.

As of this moment, there are currently around 54K+ plugins in the directory. Even though there is a vast number of plugins to choose from there are still instances that the functionality that you are looking for is not listed there and currently unavailable.

This makes it hard for non-developers that sometimes they will need to hire a developer just to have a certain functionality that they desire.

For developers, the WordPress plugin directory is the best place to host your own plugin. This can be a help to contribute to the WordPress community and a great exposure for your own works.

Just make sure that your plugin is needed and unique and it will become click.

What you’ll need:

  • A WordPress plugin created by yourself.
  • A account. (You can register here.)
  • TortoiseSVN installed on your computer or any SVN software. (You can download it here.)

Don’t have a plugin yet? You might be interested to read How to create a WordPress plugin.

Step 1: Create a readme.txt

The readme.txt file is the second most important file next to the code file in submitting your WordPress plugin. It holds information from basic to the detailed description of your plugin.

This file makes it easier for users to identify what does your plugin do and decide whether your plugin is worth downloading.

In short, this is where you market your plugin to the users.


=== Posts Unique View Counter ===
Contributors: dcangulo
Donate link:
Plugin Name: Posts Unique View Counter
Plugin URI:
Tags: post, views, counter, hits, analytics, post counter, post hits, post views
Author URI:
Author: David Angulo
Requires at least: 4.8.5
Tested up to: 4.9.4
Version: 1.1
Stable tag: trunk
License: GPLv2 or later
License URI:

Upon activation, it will allow you to easily display how many times a post have been uniquely viewed.

== Description ==

<strong>Posts Unique View Counter</strong> allows you to easily display how many times a post have been uniquely viewed with this easy to install plugin.

Just install the plugin and the counting begins. No coding skills needed.

<li> Displays how many times a post has been viewed on each post. <strong>(See screenshot-1.jpg)</strong></li>
<li> Displays a sortable view count column on <strong>All Posts</strong> page in the WordPress admin. <strong>(See screenshot-2.jpg)</strong></li>

<h4>HOW DOES IT WORK?</h4>
<li> All views of the post will start at zero (0) upon the plugin installation.</li>
<li> When a visitor viewed your post, it will save a cookie on the visitor so that same visitor will only count as one (1) view, this way we can uniquely identify each visitor.</li>
<li> The cookie expires after a month, so if the same person viewed your post after the cookie expires it will count as another view.</li>
<li> Visitors who use "incognito" or something similar will be counted always as a unique visitor because "incognito" mode does not save cookies.</li>
<li> One (1) visitor = One (1) cookie.</li>

Please rate and review the plugin if you find it useful.

Find my other works here: <a href="" target="_blank"></a>

== Installation ==

1. In your WordPress admin menu on the left hover to Plugins and click Add New.
2. Enter "Posts Unique View Counter" in the text box in the upper right corner.
3. Find the plugin entitled Posts Unique View Counter By David Angulo then click Install Now.
4. Click Activate once the plugin is installed.
5. View a post and it will start the count at 1.

== Frequently Asked Questions ==

Do you have any question? You may contact me using the email [email protected] or use the contact form on my website at <a href="" target="_blank"></a>

== Screenshots ==

1. Posts Unique View Counter running on Twenty Seventeen theme while viewing a pre-installed post.
2. Posts Unique View Counter sortable view count column in the All Posts page.

== Changelog ==
= 1.1 =
* Added view count on All Posts page.
* Added another screenshot.
* Updated the plugin description.

= 1.0 =
* Initial release.

The readme.txt above is what I use in my plugin Posts Unique View Counter.

1. The first line is where you will put your plugin name for this example the plugin name is Posts Unique View Counter.
2. Contributors are the username of the contributors for the development of this plugin. If you have more than one, you can separate it with commas.
3. The donate link is the link where can you receive donations.
4. The plugin name should be the same as number one (1).
5. The plugin uri is a valid url where they can see a detailed information about your plugin.
6. Tags are simply tags. Put the words you think that is related to your plugin.
7. The author uri is a valid link to the author page, you can put your own website or maybe your profile.
8. Author name is simply the name of the author.
9. Requires at least is the minimum version of WordPress required for your plugin.
10. Tested up to is the version of WordPress that you have tested it.
11. The version number is simply the number of versions. If you are just starting you can set it to 1.0, 1.0.0 or maybe alpha.
12. The stable tag is the version number that you can consider as stable.

You can just copy the license in here because one of the terms you have to follow when uploading your plugin is that its license must be GPL compatible.

The next is simply a short description of your plugin.

13. Then on the == Description == tag. Under it is the detailed information of your plugin. You can use HTML tags in here.
14. The == Installation == is your instructions on how to install your plugin correctly.
15. You can put Q&A in the == Frequently Asked Questions == if you have any of the users will not need to repeat questions that have been answered before.
16. == Screenshots == is the caption that will appear on your screenshots, it is matched by the number.
17. And finally, the == Changelog == is where you will put the changes for every version.
18. Icon.
19. Banner.

Figure 1.1
Picture 1.1. Screenshot 1.
Figure 1.2
Picture 1.2. Screenshot 2.
Figure 1.3
Picture 1.3. Screenshot 3.
Figure 1.4
Picture 1.4. Screenshot 4.

Step 2: Create an icon and a banner.

The icon and the banner will be displayed when it is approved in the directory.

The icon must be .jpg or .png and it is named in this format icon-128×128.jpg and icon-256×256.jpg it is better to have both of them. It must have a dimension of 128x128px and 256x256px respectively.

Same with the banner must be .jpg or .png and named banner-772×250.jpg and has a dimension of 772x250px.

If you ever have a screenshot it must also be .jpg or .png and a has a filename of screenshot-1.jpg, screenshot-2.jpg and so on. The caption that will be shown for this is in number sixteen (16).

Step 3: Zip the plugin file and the readme.txt

The zip file should look like this.

Inside the zip archive is a folder with the plugin name with no whitespaces (use dashes) then, inside the folder is your files.

Step 4: Submit your plugin for review.

Go to this link and upload the zip file you have created.

Add your plugin.
Picture 4.1. Add your plugin.
Pending Request
Picture 4.2. Pending request.

Step 5: Save your SVN repository link.

If your plugin is approved, then you will receive a congratulatory message containing your SVN repository link.

The link looks like this

congratulatory message
Picture 5.1. Congratulatory message.

Step 6: Upload your plugin to the SVN repository.

Open your TortoiseSVN Repository browser and enter your SVN repository link.

You should see four (4) directories.


The assets folder should contain the graphics for your plugin. You should upload the icon-128×128.jpg, icon-256×256.jpg, banner-772×250.jpg, screenshot-1.jpg, and the other screenshots if any.

The branches folder is like a playground where you can do testing of your code before releasing it.

The tags folder is like a folder for different versions of your plugin, just in case, your update fails then you can restore your plugin to the previous version uploaded in the tags folder.

The trunk folder is the live version of your plugin. This is where you will upload your plugin files together with your readme.txt file. The files you have submitted for review should be uploaded here.

Picture 6.1. Plugin files (left), svn repository (right)
Picture 6.1. Plugin files (left), svn repository (right)
File Upload
Picture 6.2. File Upload.

Right-click to the folder and click Add file to upload your file.

Enter a description for every file you upload
Picture 6.3. Enter a description for every file you upload.

That’s it, just make sure that you upload your file to the right directory and it should reflect almost immediately if you search for your WordPress plugin in the directory.