Sunday , 19 May 2019

WordPress Plugin Development: Create Basic WP Plugin Part 2/2

WordPress Plugin Development Part 2

This is the second part of the WordPress plugin development series for beginners who do not know a bit about WP plugin development and they really want to start making plugins for WordPress blogs. So if you didn’t read my first article (1 part) of this series then must read the first part, go to create basic WP plugin part 1/2, read and understand if you have already read it then comment there to tell us about the first part.

What We Covered in the 1 Part

In the first part of this series we covered all about how to start like the WordPress plugin directory system and basic code structure what we need to start making plugins and how to upload the plugin file so it’s very important that if you didn’t read the first part then please read it first. As in the first part I said that we are going to make a WP plugin which will change the content of the post with hello world so in this tutorial we are going to learn that how we can do it. I know it sounds really easy work to do and just useless but first you have to learn simple things before you can do advance programming or make better plugins for WP blogs as I mentioned this series is only for beginners who know nothing about WordPress plugin development.

Create Basic WP Plugin to Show hello world Instead of Post Content

So let’s get started in the first part I showed you the basic code structure so that will be same in this part too but we just have to add a new line of code to show the text as defined in the plugin code. So let’s get started just see the code below:

	Plugin Name: Your Plugin Title
	Description: Here add your plugin description.
	Author: Sohaib Ilyas (Roomi)
	Version: 1.0
	Author URI:
	function show_text() {
		$text = 'hello worlds';
		return $text;
	add_filter('the_content', 'show_text');

add_filter() function is used as a hook to launch user defined function when the WordPress function is called for more information go here. In the code above we just wrote a function as we simply write code when we develop other websites or web applications then we used the WP defined function to show the text extracted from our defined function using add_filter(), there are two parameters the first one is the name of the filter to hook the user defined function so we used the_content filter means our function show_text() is going to be called whe the filter the_content is applied.

More on WordPress Plugin Development Is Coming!

In next series I’m gonna talk about add_action() which works more deeply like connecting to database, selecting, updating, inserting data into database. You will learn to write more advance plugins so stick with us just subscribe the blog and follow me on social networks for latest updates.

Leave a Reply