How to create a WordPress Plugin



WordPress Plugins can extend functionality of wordpress up to any extent with little code 🙂

on the way i expect the reader should have

PHP general knowledge

HTML awareness

Must know WordPress and its admin interface


To start creation we should have

A Working wordpress installtion ( local / Remote)

FTP or Direct File access to its Directories

STEP 1 ( File System requirements)

Create a Folder under your wordpress installation



create your plugin file in this directory


This file must be of extension php ( say index.php ) and on the top it should cary this code

Plugin Name: My First Plugin
Plugin URI:
Description: Plugin Description
Version: 1.0
Author: meabi


STEP 2 ( Understand Hooks)



Hooks lets you to connect plugin to wordpress . ie to execute your written functions at specific times like when one post get published or when wordpress page get loaded etc etc. These hooks are again classified in to

1. Actions


2. Filters


: These are hooks that wordpress launches when specific events occur ( Eg. When some one comments on a post). With this we can specify to execute single or multipple PHP Fuctions up on events, to make clear lets have a look at our first plugin code. Action API Can be found here


Filter : These hooks are used by wordpress to modify text before sending to database or to browser screen. ( Eg. To display meessage below each post body ) . Filter API Can be found here



For demonstation i am creating a pluggin for recording last visitors ip address

Case study

To record latest visitors IP Address a function should be executed each time the site loads , here i need to use action hook, to perform this action on site load, so the code will be of the form


Plugin Name: My First Plugin
Plugin URI:
Description: Plugin Description
Version: 1.0
Author: meabi


add_action(‘wp_head ‘, ‘record_ip’);

function record_ip()




save this code into index.php ( or what ever name you like ), Now login to your wordpress Admin >> Plugins >> , Activate My First Plugin Soonafter activatig this plugin the plugin will update latest visitor ip addres.

STEP 4 (WordPress Admin Hook)

To view this Saved details we need to cretate an admin Menu

create an admin menu hook


add_action('admin_menu', 'adminMenuFunctionName');


This will look for a function with in our file named adminMenuFunctionName, Create a Function in this name (adminMenuFunctionName)
{ add_options_page('My Plugin Report', 'Latest Visitor', 'manage_options', 'Your Name', 'Options_page'); }


This will look for a function named Options_page and the menu caption will be My Plugin Report


function Options_page (){echo get_option("latest_visitor_ip");}

STEP 5 ( Activate and Use Plugin)

Now go to Admin >> Plugins

Activate My First Plugin

Visit site and check Settings >> Myplugin Report to get latest visitor IP Address




abhilash, is a programmer by profession and a technology addict with a passion towards browsing , shopping and imaging . My views may be biased on reviews. all images and videos are copyrighted to respective owners.

Add comment

Your Header Sidebar area is currently empty. Hurry up and add some widgets.