Introduction to Plugin Development
Learn to create a plugin to display post metrics.
We'll cover the following
The topic of plugin development for WordPress is vast, offering endless possibilities for customization and extension. With plugins, it’s possible to modify any aspect of WordPress by manipulating parameters, actions, and filters. While covering every single detail is impossible, this section focuses on the fundamental building blocks and commonly used features of plugin development. Armed with this knowledge, you can conduct further research on the WordPress features that you want to customize and create your own plugin accordingly.
A plugin basically leverages action and filter hooks to customize the way WordPress works. There are so many hooks available that we can customize WordPress in infinite ways.
Creating a custom plugin for WordPress
We will show how to create a plugin that count different metrics of a post like its word and paragraph count. Let’s call our plugin Post Metrics.
The first most important question is where we should create the plugin. We will create the plugin in the plugins folder inside the wp-content folder. This folder contains all the plugins we have installed on our website.
Create a folder inside the plugins folder called post-metrics-plugin. Open this folder in VS Code and create a new PHP file inside called post-metrics-plugin.php
. We should give it another name since it’s better to give the plugin file a relevant name.
Since this is a PHP file, we will enter into PHP mode on the first line. Next, we will create a comment describing the plugin as follows:
Get hands-on with 1400+ tech skills courses.