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 trialvaleriuv
20,999 PointsWhy are we using an action hook and not a filter hook? I tried add_filter and it worked.
In one of the videos, Zac said that actions hooks are when we want to do something when wordpress does something, and filters are used when we want to manipulate wordpress content.
1 Answer
Ash Matadeen
Courses Plus Student 7,185 PointsCode wise add_action()
and add_filter()
both do the same thing. In fact, add_action()
simply calls add_filter()
.
From what I understand, the idea behind using add_filter()
vs add_action()
is more to do with making it easier for someone reading the code to understand what the hook is doing.
This explains it better: http://wordpress.stackexchange.com/questions/48756/whats-worth-using-add-action-when-we-can-simply-use-add-filter