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 WordPress Hooks - Actions and Filters Action Functions in WordPress The do_action Function

Can anybody explain what do_action is and how it differs from add_action?

Hi,

I get that add_action adds your function to be run when the hook fires.

But I can't for the life of me understand from this video or from the documentation what do_action? does and how it's different from add_action

Can anyone explain this?

Thanks,

2 Answers

Micha Krapp
Micha Krapp
2,228 Points

do_action() is the hook to which you add the functions via add_action()

Ah, i see,

Thanks Micha.

So do_action should really be called something like add_a_hook / create_hook_here

Micha Krapp
Micha Krapp
2,228 Points

Yes maybe, but it does not only creates the hook it also executes hooks attached to it. That’s why the β€œdo_”