The Easy Way to Create Your Own WordPress Plugin

WordPress, the #1 choice from Global Success

The other day I was tickled when I didn’t have a simple option I needed in WordPress, so I took a stab at making a plugin for that option, and it actually worked. What I needed was just a simple option a previous plugin I was using left out, but I didn’t want to edit my functions.php file. The main reason for that was being that no matter what you want your website to do it’s not a good idea to edit your function.php file. Ever. Why not?

Even if you just make a few minor changes to your functions.php file, you still risk losing those changes unless you are using a child theme you set up for the theme your WordPress site is currently using. If you aren’t using a child theme, the changes you make in your functions.php will be erased when you update your theme. It’s not so much a risk as it is a guarantee.

Sometimes if you want to make some small changes to your website that you don’t already have the option for is by making a simple plugin. It can seem like a daunting, almost impossible task, but it is actually not as difficult as it sounds and when it works you’re going to feel next level with your WordPress skills.

To get started there is really only a few things you need to know. First off, it is important to understand what a plugin is, why we use them, and how they are written.

What is a WordPress Plugin?

Everyone that uses WordPress uses at least a few plugins. In the most simple terms they are pieces of code that when installed add some functionality to your website. WordPress plugins usually come in .zip form and contain .php files to make them work. These plugins allow you to add all kind of functions to your website without actually knowing how to code in the least. Most things you may need are probably already available to download in the plugins section of WordPress, so check that out before you go through the hassle of making one for yourself.

If you don’t know the .php language, it’s actually not a huge deal. In fact unless you want to go on to develop plugins yourself, you should just be able to Google whatever you want to paste into your new plugin. I myself have never felt the urge to learn the language, because I am somewhat lazy and also have come to find that nearly any function I want to add has been written by someone else and it freely available on the internet somewhere.

Learning computer languages is useful of course, but it not neccessary at all. I don’t do code at all, but a quip I heard a lot when I attempted to was that you should never attempt to “reinvent the wheel,” if the lines of code you need for your project have already been written by someone at some point, don’t rack your brain trying to write the code yourself.

With that knowledge in mind, what is really great practice for anyone who works with WordPress and it’s plugins is to learn how to make simple plugins to add functions that are not available otherwise.

Making Your Very Own Plugin

The great news is that making your own WordPress plugin is not really that complicated. It’s as complicated you want to make it, or just as complicated as your plugin needs to be. Even better news, I’m going to provide a download for a completely useless plugin I made, that you can edit any which way you choose. This plugin I made was useless because all it does is add an option to the plugin WooCommerce that turned out to be included all along. That aside, it is super bare boned and you can erase what I have and add whatever you please. So, click here to download “Jake’s Custom WooCommerce Functions.” (I’m Jake by the way, great to meet you.)

So the file you just downloaded is in .zip format, which is the format a plugin needs to be in to be uploaded to WordPress. Unzip the file to get started editing. Open the only file with the method of your choice to get started. The file will read like this:

* Plugin Name: Jake’s Custom WooCommerce Features
* Plugin URI: http://globalsuccess.us/the-easy-way-to-create-your-own-wordpress-plugin
* Description: This plugin takes users straight to checkout when “add to cart” is clicked on a WooCommerce product.
* Version: 1.0.1
* Author: Jacob Holmes
* Author URI: http://globalsuccess.us
* License: GPL2
add_filter (‘add_to_cart_redirect’, ‘redirect_to_checkout’);

function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;

Simple, right? Most of the text in this file is mostly attribution, a.k.a. giving me credit. The rest is just one snippet of code that I would have otherwise had to paste in my functions.php is I wanted the feature. So when my plugin is installed on WordPress it will look like this on the Plugins page:

In fact, I bet you got excited just reading those first lines from the plugin. When you open this file you can name it whatever you want. Give it a description, telling people just what your work will do for them. Replace my name and website with your own. It will be entirely your own plugin.

Right below the */ is where I started the php for the plugin. All it does is add the option to take someone directly to the checkout when clicking “add to cart.” (Again, the option is built into the WooCommerce plugin, but this is just an example file.) This is what you want to delete so you can add your own code. If you’ve searched how to fix a problem with your WordPress site and it gave you a line of PHP to add to your functions.php file, this is the time to shine.

Start with small dreams to begin with. Just take one small function that you want to add to your WordPress site that is simple enough to summed up with 5 – 20 lines of PHP, that works and is available at the whim of a Google search. Replace everything in the code above written after */ and save the file with a .php extension. You can do this in essentially every word editing program.

Once you’ve replaced the fields in the PHP file with your own name, website, and code it’s time to save it as a plugin. Zip your file with Windows Explorer or WinZip if you feel so inclined. You can now upload this .zip file to your plugins on your WordPress website. Test your plugin to see if you set everything up correctly.

Want to start from scratch? That’s not a problem. You can build your own plugin from your computer, or you could just create a folder on your website through an ftp client inside of your website’s directory wp-content > plugins. Within this folder, create a .php file with the same name as the plugin folder. You can create a .php file in any text editor. When I am trying to make some kind of file quickly, say a .html or .php file, I will just use “notepad” that has been built into all Windows operating systems since the dawn of time. When these kinds of edits became necessary more frequently I had to find a better system to do it, that was easier on my eyes.

The problem with using Notepad is the way it lays text when you open a file. It wants you to scroll from left to right, sometimes with all of the text all being on one line. That’s too much for me to deal with, when I’m writing a simple .html or .php file I use Aptana Studio 3. I’m not trying to sell you anything here, the programs completely free and open source, and if your planning on making your own plugins or writing your own scripts I would absolutely recommend this program.

Aptana is pretty intuitive for a completely free program. When you open files like .php files and similar code files the program knows how to divide the codes into multiple lines. The program also makes it simple for you to save your text files in whatever type of format you like. Most text editors can do this but some make it more difficult than it needs to be.

Get Free Email Updates!

Join over 3,000 visitors who are receiving our newsletter and learn how to optimize your website for search engines, find free traffic, and monetize your website.

I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Most Popular

To Top