WordPress is a great platform with tons of features and options. However, there are some things that it doesn't have by default. This is where a custom plugin comes in.

Custom WordPress plugin will allow you to add new functionality to your website or change the existing functionality.

Creating a WordPress plugin is not as difficult as it sounds. In fact, it's quite easy! All you need is a text editor such as Visual Studio Code, and some basic knowledge of PHP(or you can learn along the way).

Benefits of a custom WordPress plugin?

Add New Features & Functionality

Add new features, and functionality and modify WordPress the way you need it. No need to rely on third-party plugins that may or may not be updated regularly.

Organised Code

When you develop your own plugin, you have the freedom to organise your code the way you want it.

This makes your code more readable and maintainable.

Alternatively, you can use plugins such as Code Snippets instead of a custom plugin, but I still feel as a developer you can organise your code better with your own plugin, and call different templates from different locations to expand your own plugin.

Can be installed on multiple websites

If you develop a plugin that could be useful for other WordPress websites, you can easily install it on multiple websites.

I have developed a plugin for a marketing agency, that we install on every client website when we create a new WordPress website which adds the functionality we use, modifications to WordPress to make it feel more bespoke and removes all the bloat that WordPress has.

Better Performance

Your code is more organised and optimised, it puts less load on the server, making your website faster.

As mentioned above you don't need to add custom plugins to make small modifications, less code equals better performance for your healthy website.

Creating WordPress Plugin

The first thing you need to do is create a new folder inside the /wp-content/plugins/ directory. You can name this folder anything you want. I am going to call it my-custom-plugin.

My Custom Plugin Screenshot Inside the Folder

If you have WordPress set up locally it should be easy enough for you to navigate to the folder, if it's on the server then you will need to connect to it via FTP or SFTP. I recommend using local to work on your website, which is a free tool, and creating a website with local is super quick!

You should never code on a production(live) website to create a new plugin or do any coding as it may lead to errors for the end-users that are on the website while you are working on it.

Instead, work on a staging site, or work on a development website before the website is set live.

After you create the folder, inside it, create a file and name it my-custom-plugin.php. The plugin file must have the same name as the folder in which it resides.

My Custom Plugin PHP File created inside the my-custom-plugin folder

Once you have created the plugin file, open it in your text editor and add the following code to it:

* Plugin Name: My Custom Plugin
adding the header to my custom plugin

That's it, now you can go to your WordPress dashboard, and activate your "My Custom Plugin". The above is your header information for the plugin which is required.

activating my custom plugin in WordPress admin dashboard

You can also add more items to the header, see below:


* Plugin Name: My Custom Plugin
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Custom functinality for my WordPress website.
* Version: 1.0
* Requires at least: 5.2
* Requires PHP: 7.3
* Author: John Doe
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: https://example.com/my-plugin/
* Text Domain: my-custom-plugin
* Domain Path: /languages


Let's break down this code:

  • Plugin Name: This is the name of your plugin. It is required, and it should be unique.
  • Plugin URI: The URL to where your plugin is located.
  • Description: A short description of what your plugin does.
  • Version: The current version number of your plugin e.g. 1.0
  • Requires at least: The minimum version of WordPress required for your plugin to work.
  • Requires PHP: The minimum version of PHP required for your plugin to work.
  • Author: Your name.
  • Author URI: Your website address.
  • License: Read more on the GNU Website.

Now that we have the basic structure, let's add some functionality!

We will start by creating a function that will output "Hello World!" when called. The code for this will look like this:

function my_custom_plugin_function(){
return "Hello World!";
first function created inside my-custom-plugin

This function can be called anywhere on your website using the following code:

<?= my_custom_plugin_function(); ?>;
calling function from my custom WordPress plugin

And that's it! You've created a basic WordPress plugin. Of course, there is a lot more you can do with your custom plugin, but this is a good starting point.

You can now add snippets, and functions to your custom plugin.

I hope this article has helped you understand the benefits of creating your own WordPress plugin and how easy it is to do so. Happy coding!