How to Create Your First Plugin in WordPress

This tutorial on how to create your first plugin in WordPress is intended for those who have been meaning to learn this skill and get started with their own version of plugins on WordPress.

How many times have we tried to look for a plugin we want, but never come across the one that we really want for our website? There is always one or two crucial things that go missing in the plugin that we desire. It is best to create your own version, something that really fits and reflects your personal requirements.

new plugin meme

We are going to see how to create a plugin in this tutorial. We will however not go into code development as it’s a skill you need to develop on your own. We will point you in the right direction so that you could come up with your own custom-made plugins and create what you want for your website.

Here is a step by step tutorial to make you figure out how to create first plugin in WordPress.

Steps on How to Create Your First Plugin in WordPress

To create your first plugin, you need to first have access to your FTP or the cPanel of your website, you know a place from where you can access all your website folders.

Step 1: Navigate to the URL of your website’s cPanel.

cpanel look for how to create your own website

Step 2: Enter Username and Password and click on Log in.

Step 3: Look for File Manager in the bottom section. Open it.

file manager in cpanel

Step 4: In File Manager, in your public_html folder intended for your website, look for ‘wp-content’ and click on it.

wp content folder location

Step 5: On the right hand side you will see the content of the folder being displayed. Open the Plugins folder.

plugins folder located in file manager

Step 6: In the Plugins Folder, create a new Folder. You can do so by clicking on the + Folder button option as shown in the image below:

add a new folder option in plugins

When you do that a dialog box will open asking you to enter New Folder Name. Provide a name for your plugin, make sure the file is being saved in /public_html/wp-content/plugins folder.

Click on Create New Folder.

Step 7: You would notice that a new folder is created in your Plugin folder. Open that folder.

create a new folder in plugins folder

Step 8: In the new empty folder you need to create a php file. To do that, click on the + File button as shown in the image below:

how to add a file option in cpanel

Step 9: Once again a dialog box would open asking you to enter the name you wish to keep for your plugin. Provide a new file name followed by a ‘.php’ extension as shown in the image.

create new file option

Then click on Create New File.

Step 10: With that your new plugin file will get created.

renamed php file begins to show

Step 11: Now right click on the created file and click on Edit.

edit option available after right clicking your php file

Step 12: A dialog box will open. Simply click on Edit.

edit button

Step 13: Copy and paste the following details in the newly opened editor.

<?php
/**
 * Plugin Name: My First Plugin
 * Plugin URI: http://www.mywebsite.com/my-first-plugin
 * Description: The very first plugin that I have ever created.
 * Version: 1.0
 * Author: Your Name
 * Author URI: http://www.mywebsite.com
 */

Update plugin name, URI, Description, Author and Author URI based on your custom requirements.

Step 14: Once you are done, just click on “Save Changes” on the top right corner.

first plugin comments

That’s it!

Check Your Created Plugin on your Website’s Dashboard

The above-mentioned steps of plugin creation will make sure the created plugin begins to reflect on your website’s dashboard.

Step 15: To check the created plugin you can simply go to your admin page or your dashboard by first entering your website name followed by /wp-admin.

e.g.

https://yourWebsiteName.com/wp-admin
wp admin page of your website

Step 16: Login using your credentials.

Step 17: On your dashboard, find plugins on the left side column and click on it.

location of your newly created plugin

The Plugins page will begin to show your created plugin.

You can Activate it but since there has been no code it will not do anything.

Let us add a small piece of code so that it actually starts doing something.

add_action( 'the_content', 'callMessage' );

function callMessage ( $content ) {
    return $content .= 'Thank you for reading!';
}

Step 18: Go ahead and copy-paste the above-mentioned code in the same PHP file where you added the comments earlier.

update add action

Step 19: Click on Save Changes.

Step 20: Now go ahead and activate the plugin on your website’s plugin page.

plugin activation option

To see it in action, just reload your website after activation of this plugin.

You will see a small message after every post that says:

“Thank you for reading!”

thank you text on your website

It would be a good idea to learn Hooks – Actions and Filters if you want to delve deeper into understanding how to create your custom-made plugins.

Go ahead and explore and learn how to create your very own plugin.

Scottshak

Poet. Author. Blogger. Screenwriter. Director. Editor. Software Engineer. Author of "Songs of a Ruin" and proud owner of four websites and two production houses. Also, one of the geekiest Test Automation Engineers based in Ahmedabad.

You may also like...

1 Response

  1. March 30, 2022

    […] How to Create Your First Plugin in WordPress – Dumb IT Dude […]

Leave a Reply