1. Code
  2. WordPress

The Ultimate Guide to Building a Wordpress Plugin

Scroll to top
Read Time: 6 min

When it comes to adding extra functionality to a Wordpress blog, Wordpress users typically go and search for a plugin that might suit their needs. There are often plugins created for basic extended functionality, but what happens when you can't find the perfect plugin for your needs? It might be easier to just create the plugin yourself.

Wordpress has an excellent plugin framework that makes extending the core Wordpress functionality quite easy. In fact, making a simple plugin is surprisingly uncomplicated, thanks to the excellent Wordpress documentation and other helpful articles around the web.

If you think you'd like to take the plunge into writing a Wordpress plugin, here are some essential resources and tips to guide you on your way. This will carry you from the earliest stages of plugin creation to promoting your newly-created plugin, and everything in between.

Plan Before You Build

If your main motivation isn't to solve a specific need for a plugin, than there are many other ways to generate ideas and reasons to write a Wordpress plugin. Sure, you could always whip up the simple "hello world" plugin (provided in the default Wordpress installation), but we want something a little more challenging, right? If your plugin idea seems simple enough to create from scratch, try using your plugin idea as your sample application instead of spending time building a useless application that you'll never use, just for practice.

If you'd like some more ideas for building a plugin, DevLounge has created a list of ways to generate ideas for writing Wordpress plugins. Generally, the best practice is to start researching other existing plugins and work on ideas to improve them.

Gather Powerful Tools

You can't start building your plugin without setting up a proper test environment. Here are some must-have tools for building a Wordpress plugin:

  • Firefox - If you've yet to install Firefox on your computer run, don't walk, over to Mozilla and snag a download of the superior web browser. It's an incredibly useful tool for web developers.
  • Firefox Extensions - There are two really good Firefox extensions that make debugging and designing your plugin much less of a chore: Firebug and the Web Developer extension.
  • Wordpress - You'll need a clean install of Wordpress so that you can set up your testing environment on your computer.

Gather Good Information

Aside from this post, you'll need some other documents that allow you to quickly find Wordpress plugin API references. Here are a few that will come in handy:

  • Wordpress' Plugin Resources - Reference guide for all things Wordpress plugins. Tutorials and how-tos galore.
  • Wordpress Plugin API - This is your lifeline, your cheat sheet of everything that comprises a Wordpress plugin. If you're ever stuck, this is the document you'll go back and reference for help.
  • Plugin API Action Reference - The list of actions that are available in Wordpress plugins.
  • Plugin API Filter Reference - The list of filter hooks that are available in Wordpress plugins.
  • Wordpress IRC Channel - Fire up your favorite IRC client to access this pool of Wordpress developers who are willing to help with your plugin creation woes.

Create a Dedicated Test Environment

Now that you've gathered your tools and resources needed to create a plugin, it's time to set up your test environment. There are two different methods of setting up a plugin test environment. The best way to speed up your development time is to create a testbed on your own computer, using Apache and MySQL. While this can be a bit more advanced, there are tutorials for setting up different Wordpress environments with both of these technologies.

For developing on a Windows machine, try installing Wordpress using XAMPP, a nifty program that bundles Apache and MySQL together in an easy install. (Note: XAMPP is cross-platform, so Linux and Mac users can use it too.)

Another option for Mac users is to install Wordpress using MAMP, a program that bundles MySQL and Apache for use on Macs.

The second option for test environments is to just make a separate directory on your webserver and create a fresh install of Wordpress on that. You'll have to upload every change using FTP, so it will be much slower than a local test environment.

Master the Basics

Fortunately for unskilled programmers like myself, building a Wordpress plugin can be a relatively simple process. Sure, you can make incredibly advanced plugins, but it's quite easy to just dive into creating a simple plugin with the framework that Wordpress has set up.

Jarkko wrote an article on earlier this year on the anatomy of a Wordpress plugin, and this is an excellent place to start with the basics of plugin writing. The tutorial shows how to create a simple plugin that creates a widget that shows upcoming scheduled posts on a Wordpress site. A perfect resource for any beginner, complete with source files.

Access and Manipulate Database Data

Database interaction is crucial to nearly all plugins, so it's important to understand the basics of how to connect to the Wordpress database and access data. The Wordpress documents have an excellent tutorial on how to interact with databases.

Utilize Javascript and CSS

While some plugins might not need any extra styling, adding a little spice to your plugin never hurt. DevLounge has a great article on how to include elements like Javascript and CSS into your plugin.

Ajax is another element that can really make a difference in a Wordpress plugin. Sending data without needing a page refresh is a useful attribute to have in your plugin. Here are some resources on how to utilize Ajax in a Wordpress plugin:

Add a Versatile Options Page

Your plugin might require an Options menu and page to show configurable choices for the Wordpress administration section. The Wordpress Codex has a great reference page on adding administration menus. If you're wanting a tutorial with screenshots, then try Wordpress Bits' Adding Options to Wordpress tutorial.

Internationalize It!

A useful way to spread the reach of your plugin is to translate it into different languages. The Wordpress plugin framework allows developers to localize the plugin, allowing for different translations to be made.

Spread it to the Masses

Here a few of the main resources to publicize your kickin' plugin and allow other Wordpress users to download it:

  •'s Plugin Directory - The official Wordpress site is far and away the best place to promote your plugin. It has an extensive plugin directory that many Wordpress users find plugins with. Just register an account and upload your plugin. The plugin will have to be approved by to make sure that it follows their plugin guidelines.
  • Weblog Tools Collection - You can submit your plugin to Weblog Tools Collection, a widely-read blog on blog tools and plugins.
  • Wordpress Forums - You can use the Wordpress forums to find beta testers for your plugin, to make sure the plugin is free of bugs and ready for "prime time".
  • Plugin Submission and Promotion - The Wordpres Codex has a great resource on how to get your plugin in front of testers and other Wordpress users.
  • Subscribe to the NETTUTS RSS Feed for more daily web development tutorials and articles.

Glen Stansberry is a web developer and blogger who's struggled more times than he'd wish to admit with CSS. You can read more tips on web development at his blog Web Jackalope.

Liked this post? Vote for it on Digg below. Thanks!

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.