What is hooks and how to use hooks in wordpress

Hooks in WordPress allow developers to easily tie their own code in with the WordPress core code base, themes, and plugins. In this post, we’ll discover what hooks are, go over the different types of hooks, and look at a few examples of hooks in action and filters hooks.

Hook is a generic term in WordPress that refers to places where you can add your own code or change any existing functionality using hooks what WordPress is doing or outputting by default.

There two types of hooks in wordpress

  1. Action hooks
  2. Filter hooks

Action Hooks

An Action hooks in WordPress is a hook that is triggered at specific time when WordPress is running and lets you take an action. This can include things like creating a widget,shortcode,custom post types etc.

Example of Action Hook


Filter Hooks

Filter hooks in WordPress allows you users to get and modify any existing functionality of  WordPress  before it is sent to the database or the browser. Some examples of filters. There are lots of action hooks if you want to learn all functions then click here

Example of filter hook


How to Unhook from Actions and Filters

How to remove any functionality using hooks in themes or plugins

Example of remove action hooks


Example of remove Filter hooks


There are some other action hooks example like add menu in admin section



Add a Comment

Your email address will not be published. Required fields are marked *