How-To: Write a WordPress Plugin

WordPress Plugins help us to easily modify , customize and enhance the WordPress Blog. We can use the WordPress Plugins to add functionality to WordPress instead of the modifying the core programming of the WordPress.

If you need a specific functionality for your blog you must first search WordPress Repository for existing plugins to see if someone has already developed a plugin that suits your requirements. If not then you should proceed developing your own plugin which is explained below:

I assume that you are already familiar with the basic functionality of WordPress, and PHP programming.

Creating a Plugin

This section will take you through the steps of creating a well-structured WordPress Plugin.

Names, Files, and Locations

Plugin Name

You should choose a name for your plugin which describes what the plugin is going to do. For example a Stock Exchange related plugin should use wordpress Stocks in its name. You should also check the WordPress repository to check if the proposed name is available or already taken .

Plugin Files

Create a plugin file with the name based on the name of the plugin. It is not cumplosary but you should follow the rules. You can place this file directly under the /wp-content/plugins/ directory or in the directory of you plugin (e.g: /wp-content/plugins/your-plugin/

Readme File

If you want to host your Plugin on, you also need to create a readme.txt file in a standard format, and include it with your Plugin. See for a description of the format.

Note that the WordPress plugin repository takes the “Requires” and “Tested up to” versions from the readme.txt in the stable tag.

 Creating Plugin Files

Now it’s time to put some information into your main Plugin PHP file.

Standard Plugin Information

Your Plugin’s main PHP must start with the following code. 

 These lines will serve as the definition of your plugin. You can write your plugin code after these lines. The whole plugin logic will follow these lines .