WordPress Actions vs. Filters

Hey there! I'm currently working on a CLI tool to deploy WordPress apps to DigitalOcean. Check it out! It's free and open source.

If you’re still wondering about the difference between WordPress actions and WordPress filters, Michael Fields posted a very cool explanation in this forum thread called Actions vs. Filters. I think it’s the best explanation of actions and filters I have seen so far, well done Michael, and keep up the good work!

Let’s pretend that WordPress is a Mexican restaurant and we have ordered a taco as illustrated by the following code…

<?php $taco = 'chicken'; ?>

Hat tip to Philip for finding this little two-year old treasure in the forums. If you’re interested in a very detailed article about the internals of actions and filters, check out Gennady’s post called Inside WordPress Actions and Filters.

Has anyone else stumbled across interesting ways of describing WordPress functions and APIs? Feel free to share your links!

8 thoughts on “WordPress Actions vs. Filters

  1. Probably not as good, and definitely oversimplified (and written by me):

    Once again, that last block of code in plain English – “Hey WordPress, when you run register_form hook, would you be so kind to show these fields as well? Thanks!“. Kinda like, “Honey, since you’re going out to a bar, could you take out the trash as well?” but more techy. It’s adding a function (taking out the trash) to your action (going out). The filter function is different, what it says is “Honey, now that you’re going to take out the trash, could you take this heavy old chair that we don’t need as well?” – you’re still taking out the trash, it’s just a little bit different – your output (pun, pun) is being filtered!


    (hope you don’t mind the URL, but it’s out of context posted like this)

    • Thanks for sharing that Jeremy, it does look like a decent explanation of actions and filters. However, the CSS code snippets that use the heredoc syntax will break because of indentation:

      It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon. That means especially that the identifier may not be indented

      Not really related to the topic, but just as a heads up ;)

      Thanks for your comment!

Comments are closed.