Creating a plugin extends the power of WordPress. Follow along with this tutorial for a quick beginner’s course on how to begin the process of creating a custom plugin.
In this tutorial, you will be introduced to:
- Why creating a custom plugin is a better choice over modifying core theme, plugin, and WordPress files.
- Why creating a custom plugin is generally a better choice over creating custom functions in the functions.php file of a theme.
- How to install the Pluginception Plugin and use it as a very quick, simple way to create a custom plugin.
- How to start the creation of a plugin and what the minimum requirements are.
- How to delete the Pluginception Plugin after using it, if desired.
Resources discussed in the video:
It is considered bad practice to edit core files of themes, plugins, and of WordPress itself.
Filter and action hooks are often included to prevent the need for this.
If modifying core files, the changes will be lost when the core files are updated with feature updates or important bug and security fixes.
One way to include custom functions is to modify the functions.php file of a parent or child theme.
Of these 2 choices, it’s better to modify the functions.php file of a child theme.
However, if you ever switch themes, the custom functions will be lost.
In some cases though, this won’t matter if the custom functions were only used to modify the functionality of that theme.
Other times, for writing functions to do things like including custom fields in your posts, it’s best to write a custom plugin, because for that type of functionality… you will want to retain it regardless of the theme being used.
I really like the simplicity of using the Pluginception plugin to create a custom plugin. It prevents the need to interact with the File System using FTP, and comes with a template for a basic function.
For that reason, I am going to show you how to use that plugin to create your own plugin.
Let’s get the Pluginception plugin installed now.
- To install Pluginception, from your WordPress Dashboard, go to Plugins, then Add New.
- Do a search for Pluginception.
- Click Install Now, then Activate.
Now, a new menu option below Plugins will be created to allow you create a new plugin.
Let’s go through the quick steps for starting the creation of a new plugin.
- From your WordPress Dashboard, go to Plugins, then Create a New Plugin.
- Give your Plugin a name.
- Click the Create a Blank Plugin button.
That’s really all there is to the minimum requirements for a plugin.
Here you would paste in some functions that may have normally been suggested to use within the functions.php file of a theme.
After adding in your functions, save the file to see your customizations in action.
When you are done with Pluginception, you may want to delete it.
If so, follow the quick steps below.
- From your WordPress Dashboard, go to Plugins, then Installed Plugins.
- Click the Deactivate link below Pluginception.
- Then click the Delete link.
You should also watch our other create a WordPress plugin video tutorialÂ where you will learn some additional plugin creation techniques.