How to create a custom plugin in WordPress

In WordPress, you can add any type of custom functionality to your code by creating plugins. The process of creating plugin can be both easy and complicated, depends upon the functionality you want to add.

In this blog, I will provide you the beginners’ guide to create a plugin. After that you can add your functions to that plugin.

Follow the steps below:

1. Set up the plugin file structure

Create a new folder in the WordPress plugins directory:

wp-content/plugins 

and name it after your plugin. Inside that folder, create a main PHP file with the same name as the folder and the .php extension.

2. Add the plugin header

In your main plugin file, start with the plugin header. Replace the placeholders with relevant information about your plugin.

For example if your plugin name is “CustomPlugin” , the header would be like this:

 /**
 * Plugin Name: CustomPlugin
 * Plugin URI: https://custom-plugin-website.com/
 * Description: This plugin adds custom menu in the admin
 * Version: 1.0.0
 * Author: Esparksinc
 * Author URI: https://author-website.com/
 * License: YourLicense
 * License URI: https://license-url/
 */

Plugin Name: is the most important placeholder to create a plugin. Other placeholders can be added per your own requirement.

3. Activate the plugin

Go to admin dashboard>plugins>installed plugins and find the name of your plugin.

Activate the plugin.

After this, you can add your custom functions to the plugin file.