The Ultimate Guide to Building a WordPress Plugin
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:
- Wordpres’ AJAX page
- AJAX in WordPress plugins
- Simplified ajax for WordPress plugin developers
- jQuery and Ajax in WordPress plugins
- jQuery and ajax in WordPress plugin administration pages
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:
- WordPress.org’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 WordPress.org 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!


RoyalSlider – Touch-Enable ... only $12.00 
First! Just joking! No but really… my first comment!
Will read now lol, enjoy learning about WordPress!
Great list of resources Glen! There are the few times when you can’t find a plug-in to suit your needs and need to build yourself one.
ultimate guide
Ohh… I thought we’d be making a plugin!
I also thought we’d be making a plugin… but no matter. This is a nice list of resources, none-the-less.
Great write up, but I would now like to see another plugin creation tutorial.
Nice article! Rekindled some ideas that i’ve had for plugins in the past.
Yup i guess i did too. I think the article should have been named “The Ultimate Guide to [Planning] a WP plugin.”
What plugins does everyone use?
I use these, just to name a few:
(1) phpwidget
(2) Headspace
(3) WP Backup
(4) Yoast Breadcrumbs
(5) Geishi Sytax Highlighter/Code Colorer
(6) C Forms
(7) Kimli (Need to get rid of it!)
Plus lots of inactive ones, which i’ve gotten rid of…
ultimate guide indeed.
slow news week?
Always good to see stuff about wordpress :D
greetz,
http://www.opensourcehunter.com
Yeah… this one doesn’t really fit in with the other great tutorials in here… Just another list of links generated from your bookmarks…
Thanks Glen, I’ve been looking for something like this. The official WordPress docs aren’t so great for helping a beginner make their first plugin, but this certainly is!
I’m looking to take a simple php directory script and turn it into a plugin so that it displays in wordpress.
Does anyone know where I could find info on how to do this quickly? My programming knowledge is very limited.
Nice article Thank you!
Great summary what to do…
Scholars are willing to have a good degree, but what is the way to do it? We would suggest to detect for the dissertation writing service to buy the thesis mba about this post in. We took it and got really good degree.
You got it all covered! Thanks
Heh! Very nice, many thanks.
Oh my god, I was waiting to get my hands work, but it’s just only a talk which probably most of the people already have the idea…
Wonderful information!. Nice article Thank you.
OMG thank you so much for this collection of links and the outline!! I have been searching all over the internet on how to create a custom photo gallery with jquery and i FINALLY found it!!! I just need something simple that looks good and for some reason, the existing plugins are just too complex or look stupid.
I like thist blog ,Thank you for sharing! When I cliked on the title-a title I might add,which is quite good. This post particularly caught my attention. hanks for sharing look forward your new posts 8
Wow, incredible blog format! How long have you ever been running a blog for? you made running a blog look easy. The entire glance of your site is excellent, let alone the content material!
Uhm… now like to see a plugin creation tutorial. This didn’t help