Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Actions and Filters in Wordpress - What are they for? What do they do?

I'm almost through the Wordpress Actions and Filters course but I'm afraid I'm none the wiser on Hooks in Wordpress and what they're for?

Can anyone give any insights into what they're for? What do they do? Why are they useful and why do I need to know them? I've been following the track pretty will till now Thanks :)

1 Answer

Casey Ydenberg
Casey Ydenberg
15,622 Points

Basically, actions are what allow you to modify the behavior of Wordpress. If you were writing a plugin, you might hook in at several points:

  • adding a menu item to the admin screen
  • adding your CSS and Javascript files
  • displaying some HTML it a sidebar widget

As for why you need to know them, they are quite simply the only way to do these things. If you are writing plugins, you will almost certainly use hooks at some point. They aren't used as commonly in theme development, but it's still important to know why they exist. (I probably REMOVE more actions than I add in most themes, but still need to know how they work to do that...)