Wordpress Plugin Tutorial Part II - The Beggining

You should have Wordpress installed and running on your machine to follow this tutorial. If you have not yet done so, donwload wordpress and follow the installation instructions.
First of all we should put our plugin where Wordpress will detect it. In order to do so, navigate to {wordpress directory}/wp-content/plugins and create a folder "custom-comment-message". Inside the created folder create a file "custom-comment-message.php" and put the following contents in the file.
<?php
/* 
Plugin Name: Custom Comment Message
*/

echo "<h1>Did Wordpress run me?</h1>"

?> 

Now when you navigate to the "plugins" section of your Wordpress dashboard, you will see that the plugin has been detected. The following screen-shot shot shows this.

The plugin name that you see on the list is taken from the comment at the top of the "custom-comment-message.php" file. Now how do we know that Wordpress will run the plugin? To clear your doubts, activate the plugin and navigate to the home page of your blog. You will see an ugly message "Did Wordpress run me?" at the top your blog like in the following image.


Now we know that Wordpress ran the plugin. There are some other elements that you need to put in the header part of the plugin. Look at this article to know what they are.

No comments:

Post a Comment