WordPress Plugin Template

Creating your own WordPress plugin is a key step in becoming a Journeyman WP DIYer. Don't worry. It's easy. Here's a WordPress plugin template (with instructions).
diy, do-it-yourself, electrical repairs
Table of Contents

The hallmark of a Journeyman DIYer is working on custom code. And you need a place for that code. You’re going to create your own plugin for it to live in.

  • Skill level: Journeyman
  • Time: 5 minutes
  • Tools:
    • A text editor
    • Some kind of archiving software so you can create a .ZIP file
    • FTP access or other direct access to the website’s files

How to create your own custom WordPress plugin

Step 1: Create a directory/folder on your computer

Create the folder somewhere you’ll be able to find it. Name it “initials-plugin”.

My folder would be named “jwr-plugin”.

Step 2: Create a new text file on your computer

Create the file in the folder you just created. Name it “initials-plugin.php”.

My file would be named “jwr-plugin.php”. Be sure to change the file extension.

Step 3: Add the plugin template

Open your text file and paste in the following code:

/* 
Plugin Name: Josh’s Amazing, Awe-inspiring Plugin
*/

Seriously, that’s all you need. If this was a plugin for distribution, you’d have more information in there, but this is for personal use.

Step 4: Update the plugin information

This is your opportunity to get my name out of there. You can call the plugin anything you want that isn’t already in use on your website.

Extra Credit

While you’re in there, you might want to take a sec and add a table of contents. Over time, this plugin can grow enough to make finding a specific function difficult. A table of contents is an easy way to fix that.

Did you notice the “/*” and the “*/” that surrounds the plugin name? That tells your web server that everything in between is a comment. Obviously, WordPress is looking for the plugin information and can read it. But adding additional comments won’t hurt anything. In fact, it’s a best practice. For the table of contents, do something like:

/* Table of contents
1
2
3
*/

Put that below the code you already pasted in. Update it as you add functions.

Step 5: ZIP the folder

Use your preferred method to turn the folder into a .ZIP file.

Step 6: Upload the plugin

Upload the plugin just like any other.

In the Dashboard, go to Plugins > Add New and click “Upload Plugin”. Choose your file and click “Upload Plugin”.

Step 7: Activate the plugin

Click “Activate Plugin”.

Troubleshooting

Your plugin has no commands in it. It should do almost nothing.

The only way to know that it’s working is by checking the plugins page. You should see it listed under the name you gave it.

If it doesn’t work, remove the plugin from your site (deactivate and delete it). Then check these points:

  • Did you save the file before you zipped it?
  • Is the file saved as .PHP?
  • Did you archive the directory as a .ZIP file?
  • Did you upload the .ZIP file?

If none of that works, delete it and start over.

Why did we need FTP access?

You’re messing with code – the beating heart of your website. Every time you edit the code, you’re performing surgery. A single, errant quote mark or semi-colon and you can crash the entire site. 

If the site is down, you can’t get to the file through WordPress. You need to be able to delete/edit/rename files regardless of your site’s condition.

Share
Share on linkedin
LinkedIn
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on email
Email
Share on facebook
Facebook
Related
strawberry shortcake, dessert, summer

WordPress Shortcode Template

Creating shortcodes to display custom content (or vanilla content in a custom way) is a key Journeyman skill. Creating shortcodes has 2 challenges: generating the content and displaying it. This WordPress shortcode template will make displaying your custom content a breeze.

Read More »

More Posts

strawberry shortcake, dessert, summer

WordPress Shortcode Template

Creating shortcodes to display custom content (or vanilla content in a custom way) is a key Journeyman skill. Creating shortcodes has 2 challenges: generating the content and displaying it. This WordPress shortcode template will make displaying your custom content a breeze.

Scroll to Top