I’ve put together a quick survey/bunch of questions about how people use WordPress (from a plugin/theme/management perspective). I would greatly appreciate anyone who took the time to fill out the survey so I can use the results in an upcoming iThemes Training class along with some future focused writing/work. Thanks.
The moment you start digging the tiniest bit under the surface of WordPress in your attempt to either tweak your website or create a theme or plugin, you will come face-to-face with WordPress action hooks. The common question among people who are going deeper with WordPress is what are action hooks and how do I use them? So this post will answer those two questions, plus give you a boost up in your WordPress development pursuits.
What are WordPress Action Hooks?
At the very basic level, action hooks are placeholders. They are specific locations in your WordPress theme that allow functions/code/etc to hook into. The most basic examples of a action hooks, that normally exists in every single WordPress site, are the
wp_footer action hooks. Both of these are placeholders that are located at… (you guessed it)… inside the header of the theme and in the footer of the theme. Typical uses of these two action hooks are to place analytic tracking codes or to add some additional CSS files to a WordPress page.
In a nutshell, an action hook is a predefined place on your site left open by the developer of the site where the user/developer can insert specific code to expand the capability of the site.
How do you use an Action Hook?
Let’s use an example of adding some additional meta tag descriptions to the
section of our WordPress site. Because an action hook is just a placeholder, we need to create a function, a piece of code that will run in that action hook location. Our sample function will add a meta tag description to our WordPress site.