Working with Action Hooks

WordPress distinguishes action hooks from filter hooks. In this tutorial I want to take a closer look on action hooks. In case you want to learn something about filter hooks, check out the Interacting with Theme Filters Tutorial

What exactly are Action Hooks?

Action Hooks are some sort of triggers which allow you to add your own code to various parts of the WordPress core, plugins and themes without modifying the original files. They are designated points in the code where you can hook into with your own functions.

An example of this is the commonly used wp_head action hook, used by many themes and plugins to inject additional CSS stylesheets or anything else they require to sit between the <head> and </head> tags of their WordPress theme’s HTML structure. This is the reason for including wp_head(); in all WordPress themes.

Example Function:

You can use the wp_head hook to add a function in the functions.php of your child theme which adds a favicon to your WordPress website.

add_action( 'wp_head', 'themezee_hook_example' );

function themezee_hook_example() {

echo '<link rel="shortcut icon" href="'. get_stylesheet_directory_uri() .'/favicon.ico" />';


As you can see, the add_action() is the important function which links your function to the right hook. Therefore the function needs the hook name as first parameter and the function name as second one.

You can find more information about action and filter hooks on these websites: