Learn how to create a plugin in less than 2 minutes

Learn how to create a plugin in less than 2 minutes

Chris Miller's photo
Chris Miller

Published on Jul 31, 2021

2 min read

Subscribe to my newsletter and never miss my upcoming articles

WordPress plugins can be as simple or complex as you want them to be — and they are ridiculously easy to create, like, super easy.

In this article — I will walk you through creating a WordPress plugin in a way that I've come to learn, and hopefully, by the end of this article, you, too, will be able to start creating your own WordPress plugins.

Prep work

There's minimum prep work involved in creating a plugin:

  • Create a folder
  • Create a file (within that folder)
  • Add the plugin header

Create a folder

In the plugins directory, create a folder and call it whatever you want to call it. As a best practice, make sure it's lowercase, only letters, and no spaces.

Create a file

Now — create a PHP file and as a best practice, name it the same way you did with the folder.

Add the plugin header

For WordPress to detect your plugin, you must include the plugin header at the top of the file you just created. You can use the example below and replace "YOUR PLUGIN NAME" with anything.

<?php
/**
 * Plugin Name: YOUR PLUGIN NAME
 */

Activate the plugin

Navigate to your plugins menu in the backend of WordPress, and you should see the new plugin appear in the list — go ahead and activate it!

There — that's it, you've created a plugin!

giphy (1).gif

Wrapping up

Although plugins require a lot more than that to be of any use — the point I want to illustrate to you here is that a plugin is no more than a folder that will end up containing one or more PHP files and other dependencies that extend WordPress.

This concept is true in almost any CMS platform and JavaScript frameworks such as React, Vue, Angular, Svelte, etc.


Keep reading

This is a series that will teach you how to build a plugin from scratch.

We will get out hands dirty, and by the end of this series, you should be able to take an idea that you have and turn it into a plugin yourself!

Scroll down to find the other articles in this series.

Did you find this article valuable?

Support Chris Miller by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this
Proudly part of