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

Sam Gord
Sam Gord
14,084 Points

i have problem understanding what he's saying!

when he wants to explain what do_action does , he says: execute where in the code you want a hook to take place!

can someone please explain it a little more clearer , probably with an example of real world usage of it?

thanks in advance .

1 Answer

When WordPress loads you can use hooks to "hook" into the load process. So lets say I want to write a custom menu for the dashboard. I would look for the hook that loads the dashboard then create a callback function to load my own menu for the dashboard. This will read my add_action() and render the custom code to the dashboard.

here is a solid blog post about hooks.