How To Create A WordPress Plugin – DreamHost


One of many most important causes that WordPress is so standard is its open-source nature.

Due to that, on the time of this writing there are over 60,000 WordPress plugins which were developed for the web’s favourite content material administration system (CMS).

And you may take part on the enjoyable by creating your personal WordPress plugin.

Fortuitously, WordPress makes the method fairly straightforward. Some coding information can be wanted, however it’s not terribly arduous to discover ways to create a primary plugin so as to add further performance to your web site. And if it goes rather well, you might even be capable of promote it to others and switch your venture right into a facet hustle!

Able to study extra about why you may need to create a WordPress plugin, in addition to find out how to develop your individual?

You’re in the appropriate place!

A Fast Intro To WordPress Plugins

WordPress has a market share of almost 63% amongst all CMSes, making it the preferred possibility by a landslide.

DreamHost Glossary


WordPress is an open-source Content material Administration System (CMS). Since it’s free and accessible, WordPress is used to energy nearly any sort of web site, from blogs to e-commerce companies.

Learn Extra

As talked about earlier, WordPress is an open-source software program platform. Which means its supply code, plugins, and themes can be found for anybody to work with and modify as they see match.

Word: There’s a distinction between and The .org model is the open-source possibility that’s free to obtain and use to create a customized website. It’s the model we’ll cowl on this publish. The .com model is a hosted website builder with which you’ll create a restricted website at no cost.

WordPress plugins are packages of code that reach the performance of a WordPress website. They’re created by totally different builders all world wide and are designed for a wide range of functions.

As an example, within the current plugin library you’ll discover choices for including social media share buttons, including publication signup types to your sidebar, bettering web site SEO (search engine optimization), turning WordPress right into a full-blown ecommerce website, and far more.

The WordPress plugin ecosystem empowers these with out coding information to create and customise highly effective web sites. Moreover, it gives nearly limitless alternatives for professional builders and internet fans alike.

Get Content material Delivered Straight to Your Inbox

Subscribe to our weblog and obtain nice content material identical to this delivered straight to your inbox.

Why Develop A WordPress Plugin?

WordPress has one of many largest markets for builders. This implies you’ll discover loads of sources that will help you develop the precise plugin it’s essential to optimize your web site. (However don’t fear, we’ll additionally element the method right here quickly!). You gained’t discover that degree of assist on many different website-building platforms.

The magic of WordPress is that you would be able to develop an answer on your personal website and also you don’t should share it on the plugin market. Nevertheless, many builders select to make their plugins obtainable to others to assist them work round comparable points as these the builders encountered.

In case you do select to supply your plugin to others, there’s some incomes potential related to WordPress plugins due to the large consumer base.

Whereas there’s no scarcity of competitors, when you’ve got a brand new or higher answer to a standard drawback, you could possibly discover your plugin downloaded for hundreds of web sites. With an incredible plugin, the appropriate pricing technique, and a few advertising and marketing efforts, a plugin may flip into a pleasant passiveish revenue stream.

hypothetical math showing how much one could make by developing a plugin assuming 10,000 active users times 2% conversion equals 200 sales/year times $50/annual subscription equals $10K

Lastly, WordPress is a perfect platform for studying find out how to code. As a result of it has been round for over 20 years, there’s a seemingly limitless variety of sources each on and off WordPress that will help you get the dangle of improvement.

Talking of sources, let’s dive into all the pieces it’s essential to know to create your very personal WordPress plugin.

How To Create a WordPress Plugin (6 Steps)

Whereas totally different plugins would require totally different quantities of coding and know-how, all of them are likely to observe this similar normal improvement course of.

Step 1: Do Your Analysis And Planning

Like we stated, there are quite a few instruments within the WordPress plugin listing — tens of hundreds of them in actual fact. Due to this fact, the very first thing you’ll need to do is do a little analysis to see in case your thought already exists.

Even when it does, you may nonetheless proceed together with your plan, supplied that you just make some tweaks so that you just’re not creating a precise duplicate. Discover comparable plugins and learn the way you may be capable of enhance upon them. Alternatively, you could possibly complement what’s already obtainable with one thing like your individual customized publish sort — say, to assist hold a diary of your media consumption — or further options.

You may also need to examine the standing of current plugins. As an example, if a plugin hasn’t been up to date in a while or isn’t suitable with the most recent model of WordPress, there is likely to be a chance to offer a greater answer.

You may as well take a look at the variety of lively installations to see if there’s a giant marketplace for the kind of plugin that you’ve in thoughts. This may also help you determine if it’s well worth the effort if you happen to’re trying to earn cash. It’s additionally a good suggestion to check the plugin by yourself website to see what it does properly and what might be completed higher.

Lastly, earlier than diving into the construct, you’ll need to learn up on the WordPress Coding Requirements. That is notably essential if you happen to’re planning to share or promote your plugin. These coding requirements are a set of pointers and finest practices that builders ought to attempt to adhere to when creating themes and plugins for WordPress.

Associated: Need To Study WordPress? Begin With These Assets

Step 2: Set Up A Testing Surroundings

The following step is to arrange a testing setting.

As a newbie, you’re prone to study (and perhaps break) a number of issues alongside the best way. You don’t need to experiment in your stay web site that any web consumer can see. A neighborhood setting — a staging web site — will allow you to check your plugin privately as you’re employed on it.

We promote utilizing Native to create a WordPress website in your laptop. It gives a simple, user-friendly improvement setting that gives highly effective but versatile instruments for most individuals.

You may as well create a web based staging setting. With DreamHost webhosting, you possibly can simply create a staging WordPress website the place you possibly can take a look at your plugin with out breaking your stay website or interrupting your guests’ consumer experiences.

Step 3: Create Your Plugin File

Upon getting your staging setting arrange, it’s time to make use of it to create your plugin.

Step one is to create a folder for it in your website’s listing.

You should use an FTP/SFTP consumer like FileZilla to entry your website’s information and folders. Or, you could possibly faucet into your website by way of the file supervisor supplied in your internet hosting account. For DreamHost customers, our information to utilizing the web site file supervisor will allow you to use our built-in file supervisor.

When you’ve linked to your website’s listing, navigate to wp-content/plugins and create a brand new folder on your plugin.

Subsequent, you’ll must create a PHP file so as to add to this folder. To do that, open your most well-liked textual content editor and enter the next info:

* Plugin Identify: test-plugin
* Plugin URI:
* Description: Check.
* Model: 0.1
* Writer: your-name
* Writer URI:

In fact, you’ll want to vary the above info to match your particulars. If you’re prepared, it can save you your file. Bear in mind to make use of the file extension “php” (e.g., my-first-plugin.php).

Then, you’ll must add this file to the plugin folder that you just simply created at wp-content/plugins. When you’ve completed this, navigate to your take a look at website’s WordPress dashboard and go to the Plugins web page.

screenshot showing the plugins option on a wordpress menu

Right here, you must be capable of see your new plugin!

This plugin gained’t do something but if you happen to have been to activate it. Nevertheless, WordPress will acknowledge it as a practical add-on from this level ahead.

Step 4: Add Code To Your Plugin

Each plugin is totally different. Nevertheless, all of them share frequent elements. As an example, all plugins use hooks to work together with WordPress.

DreamHost Glossary


WordPress hooks are items of code that assist you to modify the CMS and add new options to it with out tinkering with core information. Hooks make this potential by enabling you to “hook” customized code into pre-defined spots in WordPress.

Learn Extra

A hook is how a plugin connects to the pre-existing code of WordPress’s core programming. In different phrases, the hook is the anchor level the place a plugin inserts itself as a way to add or change the performance of a website.

Hooks are an essential a part of WordPress improvement. There are a whole bunch of hooks that can be utilized as triggers for a plugin, and you’ll even create new ones if wanted.

However for now, there are two forms of hooks that you just’ll want to think about when creating your plugin:

  1. Actions: These add or change WordPress performance and make up the vast majority of hooks.
  2. Filters: These are used to change the performance of actions.

To code your plugin, you’ll must familiarize your self with hooks and the way they work. Fortuitously, the Plugin Handbook from WordPress may also help you get began.

For this information, we’ll use the next code (supply) for instance:

perform modify_read_more_link() {
    return '<a category="more-link" href="' . get_permalink() . '">Click on to Learn!</a>';
add_filter( 'the_content_more_link', 'modify_read_more_link' );

As you may be capable of see, this code makes use of a filter to change the usual “learn extra” hyperlink by changing it with a unique worth: “Click on to Learn!”

In case you add this snippet to your PHP file and activate the plugin in your website, you’ll find yourself seeing the next anchor textual content under your publish excerpts:

example of this plugin at work with a header image, some text, and a "Click to Read!" call to action

Be happy to experiment with the code and take a look at utilizing a unique perform.

Word that you just may additionally add this code to your theme’s features.php file. This file accommodates code that provides performance to your website and works in a method that’s just like how a plugin provides performance. Nevertheless, if you happen to change to a unique theme sooner or later — or your theme is upgraded to a brand new model — you’ll lose these adjustments.

This type of code works just for Basic themes. Block themes work otherwise and infrequently require no PHP code since all the pieces is constructed utilizing Blocks utilizing solely the Website Editor.

Additionally word that the code within the instance plugin above works just for websites using basic themes. In case you’ve been utilizing the positioning editor constructed into WordPress — which has been within the core software program for a number of years now — to lay out your website utilizing blocks, the code above gained’t do a lot for you.

Associated: How To Set up A WordPress Theme (Tutorial)

Step 5: Check Your Plugin

As you proceed creating your plugin, it’s essential that you just save your work typically and take a look at your adjustments in your staging or improvement website.

When you’re happy together with your plugin, you must strive it on a stay website. Once more, you’ll need to just be sure you’ve already totally examined your plugin for any bugs and vulnerabilities.

It’s additionally a good suggestion to create a backup of your stay website earlier than testing your plugin on it. This manner, if something does go fallacious, you possibly can restore your content material.

In case you’re pleased with the efficiency of your plugin at this level, you could possibly supply it to different builders for them to make use of and take a look at. This may earn you precious suggestions. You possibly can additionally ask them to place your plugin by means of its paces and attempt to break it to show its stability.

To do that, you’ll need to export your plugin to a zipper file for simple distribution and set up. Find your plugin’s folder within the website’s listing, then right-click on it and observe the steps to create a zipper file. For instance, on Microsoft Home windows choose Ship to > Compressed (zipped) folder.

Select a vacation spot, and the information inside your folder can be compiled into a zipper folder that you would be able to simply share. In case you’re creating on a stay website, you might must first obtain the plugin folder out of your SFTP consumer earlier than compressing it.

To put in your plugin on a WordPress website, merely navigate to Plugins > Add New Plugin from the sidebar in your WordPress admin panel.

screenshot of the "add new plugin" option on a wordpress navigation menu

On the prime of the web page, you’ll see a button to Add Plugin. As soon as chosen, you’ll be prompted to decide on a zipper file to add to your website.

screenshot showing "if you have a plugin in a .zip format, you may install or update it by uploading it here" with a choose file to upload button

Add the compressed file you simply made and choose Set up Now. WordPress will then unpack and set up the plugin in your website.

As soon as that’s full, simply click on on Activate Plugin.

Your new plugin is now stay!

Step 6: Distribute Your Plugin (2 Choices)

Now, you can begin distributing the plugin you’ve created. Let’s take a look at the very best methods to do that.

A. Publish Your Work To The WordPress Plugin Listing

By including your plugin to the WordPress plugin listing, you possibly can share your work with the group and acquire publicity. You may benefit from the WordPress consumer base to draw new purchasers.

Nevertheless, you’ll must be sure that your plugin complies with finest practices and the Detailed Plugin Tips earlier than importing it for assessment. Bear in mind, it would take some time on your plugin to be reviewed and accepted.

As soon as your plugin is accepted, you’ll want so as to add your information to the Subversion listing.

When that is all completed, WordPress customers will be capable of set up your plugin on their websites.

B. Share The Plugin On Your Personal Web site

Along with importing your plugin to the WordPress listing, you could possibly additionally create an internet site for it.

You should use a website like this to market and supply extra particulars about your plugin. You possibly can additionally embody documentation, tutorials, assist choices, hyperlinks to different plugins you’ve made, and so forth.

Builders typically use web sites to advertise their premium plugins whereas offering a free or “lite” model within the WordPress listing. That method, customers are in a position to simply discover and obtain the product by way of WordPress earlier than upgrading to a paid possibility.

You may lock sure superior options behind a paywall, which might all be defined on a plugin web site. Moreover, you possibly can supply a multi-tiered membership mannequin that gives a wide range of function units relying on a consumer’s wants and funds.

Set Your self Up For Plugin Success With DreamHost

As an open-source platform, WordPress lets you develop your individual plugin and share it with different customers. Whereas some coding information will definitely be useful, you possibly can simply create a easy plugin and vastly enhance your website’s performance by following the steps above.

When you’ve gained sufficient expertise, you might even need to begin promoting premium variations of your plugins for a rewarding and principally passive revenue stream!

However to actually set your self up for fulfillment, you want to have the ability to spin up an reasonably priced plugin testing website — DreamPress may also help you with that — in addition to a number of advertising and marketing websites to show and promote your premium plugins. Use our AI-powered enterprise identify generator, reasonably priced area identify discovering and registration service, and WordPress-specific web site builder to go from plugin thought to viable facet hustle with ease!

Do Extra with DreamPress

DreamPress Plus and Professional customers get entry to Jetpack Skilled (and 200+ premium themes) at no added price!

Managed WordPress Hosting - DreamPress