A few ways to create a WordPress Plugin

There are many ways to create a WordPress Plugin and it all depends on the requirements of the plugin that defines how complex the steps need to be, here are a few ways I create plugins for my projects.

Simple WordPress Plugin

For the most basic and simple plugin that only changes or adds the smallest amount of functionality the only thing you need is a named folder in your plugins directory and a PHP file with the name of your plugin, I usually use the same folder name as the file within it.


In the file called simple-plugin.php you need to add the following in a PHP block and save the file, this validates the file as a plugin and lets WordPress know what information to display in the backend …

 * Plugin Name: Simple Plugin
 * Plugin URI:  https://example.com/
 * Description: The minimum requirement for basic plugin.
 * Version:     1.0.0
 * Author:      Elliott Richmond
 * Author URI:  https://elliottrichmond.co.uk/
 * License:     GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: simple-plugin

In the backend of your WordPress site, the plugin should now be ready to activate.

Now this is the absolute minimum required to get started and I wouldn’t recommend you just leave it like this because there are lots of other things to consider for security but that isn’t in the scope of this article.

Create a WordPress plugin using wp-cli

This is slightly more advanced and requires you have wp-cli installed locally.

Making sure you ‘cd’ into your local WordPress root directory, you can then use the following command.

$ wp scaffold plugin sample-plugin

This will generate a whole set of files in the plugins folder with the name used in the command. Again this will set up the most basic of plugins but with the addition of other useful files for local development including a setup for PHP unit testing and Git ignore configurations.

Create a WordPress plugin using third-party boilerplate

There are multiple resources for this process with many to choose from in Github but by far my favorite has to be the WordPress Plugin Boilerplate Generator which is the foundation of Tom McFarlin’s original boilerplate now maintained by Devin Vinson.

I personally use this resource a lot as the structure is well suited for OOP plugin development. The frontend is separated from the backend and uses different PHP classes for both which makes things easier to maintain when it comes to more complicated plugins you might need to develop, there is some built-in security which should never be assumed but is useful none the less, a structure for language .pot files are set up and ready for use and probably my favorite bits are the ready built activation and deactivation hooks.

All you need to do is head over to https://wppb.me/ and input a few basic parameters then generate the plugin, the generation will automatically start a .zip download that you can unzip and add to your plugins folder ready for activation and the start of your WordPress Plugin development.

There you have it, a few ways to create your plugins.


Leave a Reply

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