Table of Contents |
1. Types of Hooks in WordPress |
2. Actions Hooks |
3. Filters Hooks |
Hooks are the functions used to modify the existing code in WordPress. Hooks can modify the code of plugins, themes, and even default WordPress functionality.
Types of Hooks in WordPress
There are two types of hooks available in WordPress Actions & Filters. Both hooks used by the plugins and theme developers to interact & modify the WordPress core functionalities.
1. Actions Hooks
Actions hooks look like an event. As the event runs at a certain point the same way Actions hooks run at a certain point in the execution of WordPress.
For better understanding, let’s see some examples of Actions Hooks in the very simplest words.
- Send emails when your blog post published
- Add database entry when someone login to your site
- When users delete their account then remove all data with it
Are you getting it? It’s so simple to understand.
2. Filters Hooks
In very simplest words Filters hooks are used to modify the data. Filters hooks take the data and modify it and return it with the newer version.
For better understanding, let’s see some examples of Filters Hooks in the very simplest words.
- Change the default length of the excerpt
- Add CSS Class or ID in body tag when certain condition met
- You can change the title, style, and other pre-defined data too