
Wordpress is the most robust platform, for the Blogging as well as for Content Management System Websites. Wordpress allows you to code and extend its capabilities using you own innovations.
In this tutorial, I’ll show you how to write a basic Wordpress Plugin. Coding a wordpress plugin, should have a basic php knowledge, the functions, the operators, the statements, etc…
Before I begin coding the Basic Wordpress plugin, I want to share some key points to kept in mind during your development.
- Choose a unique and name with relevance to its functionality, for your plugin.
- Indentation and Comments should be always used, so as to ease the understanding of the Plugin Coding.
- Test your plugin on Wamp servers, that is on localhost, with latest version of wordpress.
Basic Content
Wordpress plugin consists of two basic files, one is the main php script file, and other optional but important, readme.txt file. These files can be either archived in a folder and can be placed under the WP-Content>WP-Plugin Directory.
Plugin Information
Open the my-first.php with the notepad or any php editor, like I use EnginSite Editor for PHP. Code the below mentions lines, which stores the information about the Plugin.
Code:
<?php
/*
Plugin Name: My-First
Plugin URI: http://wordpress.org/#
Description: This is the most basic wordpress plugin, gets input from the user and displays it on every page.
Author: AkyJoe
Version: 1.0
Author URI: http://www.themepremium.com/
*/
?>
Save the php file and login to the Wordpress Dashboard > Plugins, you will find this the plugin listed, and waiting for the activation.
Plugin Working
At this, point we have achieved our goal to list the Plugin under Plugin Directory of the Wordpress Admin. Before activating the Plugin, we must code, the main objective of the Plugin. The working of the Plugin. Below is a simple function made to echo a string text, when we activate this plugin.
function my_first()
{
echo “My First Wordpress Plugin Works Fine.”;
}
Testing Plugin
In order to test the working of My-First Plugin, we will have to add a function call code in Single.php, Index.php or it can be Header.php. For instance, I added the code in the Single.php
Code
<?php if(function_ exists(‘my_first’)) { my_first(); } ?>
Now testing the above code on the Single Post Page of the Wordpress Blog. The below screen shot says everything.
This ends our basic tutorial for Wordpress Plugin Development. For any queries or any other assistance, post comments as your feedbacks.
|
Related posts: |
![]() |









{ 1 trackback }
{ 2 comments… read them below or add one }
I always wondered how hard it was to create a plugin. I guess the hard part is coming up with something original and then coding that.
This is okay! Just printing something is okay!
But can you give us some fair idea about how other plugins are created, not just printing. I know different ideas are executed differently!