
Another day, another new series: WordPress Development. This series will focus on – you guessed it – developing plugins for the popular blogging platform – WordPress. This week, we’ll talk about the theory behind developing for WordPress.
Introduction
WordPress contains a very useful Plugin API (Application Programming Interface), where you can change, add and even remove almost anything, anywhere within WordPress (within reason, of course). As WordPress is written in PHP, plugins must also be written in PHP. The API works by “hooking” into filters and actions which are placed all through WordPress at key places.
Differences Between a Filter and an Action
In WordPress, a filter is something that you would hook into if you want to filter data, being passed through a certain point, before it reaches its final destination. A filter will always give you data. An example of this would be if you wanted to remove cuss words from comments before they’re display, you would use a filter.
An action would be used when you want to simply output something to the user at certain places or points of time. An action will never give you data. An example of this would be if you wanted to add a CSS stylesheet (on-the-fly) to the Plugin user’s theme’s header.php.
Whether you’re using a filter or an action, you always return your data for it to get back into the “data stream”.
There are literally hundreds (if not thousands) of filters and actions contained within WordPress, the majority of which can be found on the WordPress Codex. The Filters reference is here and the actions reference is here.
That’s It
The entire WordPress Plugin API is simply made up of filters and actions. There’s nothing else to it, it’s just all up to you to make good use of those filters and actions.





Tyler
December 31, 2008 2:34 pm
I’ve modified some of my actions and filters to work the way I want them to work. It’s pretty crazy. I’ve also added my own actions/filters (for plugin creation). It’s pretty neat though i don’t recommend people doing it unless they know PHP
Matt Freedman
January 1, 2009 12:23 am
Luckily, we have a series on learning PHP the day before this series. :)
caminandosolo
January 1, 2009 4:18 pm
18 months ago, I was working with the WordPress API (extracting recent post to insert them in pages outside wordpress, making a tag cloud with the contents of selected posts…). After that have not contact with the WordPress code. Do you know if API or source code is different in the new 2.7 version?
Matt Freedman
January 1, 2009 10:55 pm
No, the API has not changed with WordPress 2.7, however more filters and actions have been added to it (in line with the new features).
caminandosolo
January 2, 2009 3:10 pm
Thanks. I’ll review the API because I want to customize the page for especial contents in a customer’s blog.