Adding WP Action & Filter Hooks

WordPress Banner

There are two types of WP hooks that can be used to extend the abilities of WP functions.

Filter Hooks

The following will output “Hooked: Home” to the “the_title” WordPress function on every call to the function.

add_filter("the_title", "dl_title");
function dl_title($title) {
  return "Hooked: " . $title;
}

Important: This will always return something.

Action Hooks

After the exection of the wp_footer, the following verbiage will output AFTER: Shoutout to all the WordPress devs!

add_action("wp_footer", "dl_footer_shoutout");
function dl_footer_shoutout() {
  echo "Shoutout to all the WordPress devs!";
}

Prioritization

Specific functions can be called at different times using prioritization.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: