How to Create a Custom Plugin in WordPress


Creating your own custom plugin is not rocket science. That’s right you can create your very own WordPress plugin from scratch without much difficulty. Anyone with skills enough to write basic PHP and modifying a theme can create a plugin.

A plugin is a simple program that has a set of functions, that adds a specific set of features and services which can be executed in different sections of your WordPress website.

This is how we started the K2 Blocks plugin (it’s free so you can try it) and that’s how you can start yours too.


Most people edit the theme to customize and add functionality to get the result they want for their website. This is fine but there are also cases where adding custom functionality to a plugin is a better option and here is why.

Consider this scenario that if for some reason you had functionality to your theme and it works but when you change the theme that custom functionality will be gone on the other hand if you would have customized the plugin instead of the theme the functionality would still be there.

Now let me show you how to start with plugin development.


The first thing we need to do is access our site using FTP. FTP stands for File Transfer Protocol. Its file manager is used to access files from the site. Many hosting providers also provide the file manager with it. so that they can upload or download files from their web hosting server directly from within their control panel. WordPress users may need an FTP client to upload WordPress files to their web hosting server before they can install WordPress.

If you want to more about FTP click here.

After accessing the site from FTP. You need to get the WordPress plugin folder. The Folder is Located at a /wp-content/plugins. Here create a new folder by giving it a unique name in lowercase letters such as the first-plugin after that enter into the folder and got to the next step.


Next, we will create the main file for our plugin. To do that, we create a PHP file within our new plugin folder and give it the same name such as first-plugin.php. After you’ve done that, open your plugin’s main file and get ready to do some editing.

Now, copy and paste the plugin information below into your main plugin file. Make sure to edit the details such as Plugin Name and Plugin URI as they pertain to your plugin.



 * Plugin Name: Our First Plugin

 * Plugin URI:

 * Description: The very first plugin that I have ever created.

 * Version: 1.0

 * Author: Your Name

 * Author URI:


That’s it! You’ve just completed the minimum number of steps that are required to create a WordPress plugin. You can now activate it within the WordPress admin and revel in all of your glory.

Now that you have a plugin, let’s make it do something.

The easiest way to make things happen in WordPress is with actions and filters. Let’s explore that by creating a simple action that adds a line of text below all of the posts on your site. Copy and paste this code into your main plugin file (below the plugin information) and save it.

add_action( ‘the_content’, ‘my_plugins_text’ );

function my_thank_you_text ( $content )


    return $content .= ‘ Thank you for reading!



This code hooks into “the_content” action that fires when WordPress renders the post content for your site. When that action fires, WordPress will call our “my_plugins_text” function that is defined below the “add_action” call.

Also Read : How to Restore WordPress from Backup.

When you’re going to start coding your plugins. I highly suggest you familiarize yourself with how actions and filters work and which ones are available for you to use. WordPress Codex is where you will find more about it.

Plugins API: Actions and Filters

Plugin API: Action Reference

Plugin API: Filter Reference

If you haven’t already, create your first plugin!

Creating WordPress plugins is extremely liberating and a great way to gain a deeper knowledge of how WordPress works. If you haven’t already, I strongly urge you to try your hand at creating a plugin. If you do and come up with something useful, don’t forget that you can distribute it freely to others via the WordPress plugin directory.

K2 Plugins has developed K2 blocks which is a WordPress plugin You can contact us for custom plugin development at our Official site

Have you already created your first plugin or plan on creating one soon? If so, I would love to hear about it in the comments below!

61 thoughts on “How to Create a Custom Plugin in WordPress”

  1. I love reading through an article that can make men and women think. Also, thank you for allowing me to comment!

  2. That is a good tip especially to those new to the blogosphere. Simple but very precise informationÖ Appreciate your sharing this one. A must read article!

  3. Thanks, I’ve just been searching for info approximately this subject for ages and yours is the greatest I have found out till now. But, what concerning the conclusion? Are you positive concerning the supply?

  4. After I initially commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get 4 emails with the identical comment. Is there any means you’ll be able to take away me from that service? Thanks!

  5. Thank you very much for sharing. Your article was very helpful for me to build a paper on After reading your article, I think the idea is very good and the creative techniques are also very innovative. However, I have some different opinions, and I will continue to follow your reply.

  6. Fine way of telling, and nice paragraph to take data regarding my presentation topic,which i am going to present in institution of higher education.

  7. I like the helpful information you supply for your articles.I will bookmark your blog and check again right here regularly.I’m relatively certain I’ll be told lots of new stuff right righthere! Good luck for the next!

  8. Very nice post and straight to the point. I am not sure if this is truly the best place to ask but do you folks have any thoughts on where to employ some professional writers? Thank you 🙂

  9. Normally I do not learn article on blogs, but I wishto say that this write-up very forced me to take a look at and do so!Your writing taste has been amazed me. Thanks, very nice article.

  10. Sweet blog! I found it while surfing around on Yahoo News.Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem toget there! Thank you

  11. I am not sure the place you’re getting your info, but great topic. I needs to spend a while learning more or figuring out more. Thank you for wonderful information I was in search of this information for my mission.

  12. Hello There. I found your blog using msn. This is a really wellwritten article. I’ll make sure to bookmarkit and come back to read more of your useful info. Thanks for the post.I’ll definitely return.

  13. I want to to thank you for this great read!! I definitely loved every bit of it. I have got you book marked to check out new stuff you postÖ

  14. I may need your help. I tried many ways but couldn’t solve it, but after reading your article, I think you have a way to help me. I’m looking forward for your reply. Thanks.

  15. Thanks for another wonderful post. Where else could anybody get that type of information in such a perfectapproach of writing? I have a presentation nextweek, and I’m on the search for such information.

Leave a Comment

Your email address will not be published. Required fields are marked *