WordPress Hooks – .com

In today’s tutorial we see how to detect all WordPress hooks in a very comfortable and visual way, through a plugin that will make our lives easier.

What are WordPress hooks?

Good question! The hooks are some “places” or “locations” that are distributed throughout WordPress, in which we can add our code, or modify the existing one. This is what makes plugins possible!

We have two types of hooks. And we can define them as follows:

  • Action Hooks: These allow you add or remove code in different parts of WordPress.
  • Filter Hooks: These allow you Modify data What’s inside the code.

This definition leaves a lot to be desired and is by no means exhaustive, but if you want to go into detail, take a look at the and at the . There you will see exactly what they are, how they work, and why they are key to WordPress.

How many hooks are there?

Thousands of them. Only in WordPress we already have more than 2,000 between and . Crazy let’s go But those are just the WordPress ones. actually there is many more, because all the themes and plugins we install also have their own hooks. Or it is crazy.

Without going into detail, we can say that Hooks are what allow us to modify WordPress, a theme or a plugin “without touching it”. And why is it so important? Because this way we can update WordPress, plugins and themes without losing those modifications.

So, we start from the idea that there are a lot of hooks, and that they are everywhere. I guess it’s clear that it’s impossible to memorize them all, unless you’re gifted. So… How can we know which hook to use? How can we know where to find it? Even… How can we even know if it exists??

See also  Video course #9. Video Editing - .com

locating hooks

The ideal would be to enter the bowels of WordPress and search there. When you want to modify something, you go to that file, look through the lines of code, and when you see an action called do_action either apply_filters, you already have it. This is the point where you have the option to add, remove, or modify code.

On the other hand, we also have hook search engines, being one of the most recommended, in which we have an impressive library of invaluable hooks. That website is worth all its weight in gold, and what’s more, it’s free. The magic of open source!

On this website we can search and find all the WordPress hooks and hundreds of themes and plugins. From WooCommerce to BuddyPress, passing through Gravity Forms, Pods, etc. At the time of writing these lines, it already has 884 plugins and 59 themes.

In addition, the search engine that it has works great, and on many occasions, just searching with a little common sense, we will find the hook we need, and it will also tell us in which file and line we can find it.

But there’s still more

But if you haven’t fallen in love with this yet, prepare yourselves, because recently, hookr already has a plugin. Yes sir, now we can install a plugin that will help us a lot to detect all those hooks, and locate them. And on top of that it’s free. Had I already said it?… The magic of Open Source.

you can Once you install and activate it, you will see all the available hooks on your site:

See also  Direct Billing Course - .com

If you are not programmers, this will sound Chinese to you. But if you’re a WordPress developer, this will make your day, year, and decade. It is truly an extraordinary tool.

This is exactly what we see in the Genesis Visual Hook Guide, but for “all WordPress”.

In addition, selecting those hooks gives us all the related information: A description, the file that contains it, on which line it is executed, the values ​​it has by default, and even categorizes it for us.

And the thing does not end here. We can also filter the hooks in real time, through the search engine that we have in the administration bar, something more than interesting to remove everything that is “excess” from the middle.

configuring hookr

We can even go further, since this plugin has an options page (in Tools/Hookr) that allows us to select what type of hooks to show, both in the frontend (the website itself) as in the backend (control panel).

As you can see, we can filter by actions or filters, by context, or even by its own nature. In addition, we can also create our own “blacklist” of hooks that we don’t want to see because we don’t care:

And obviously, we can also do the opposite, and see only those that interest us, with a “white list”:

In short, we can customize this tool according to our needs, to be much more productive. And attention, it is only the first version of the plugin. What is to come is even more promising.

See also  Using Custom Post Types in WordPress - .com

Summary and conclusion

WordPress has thousands of hooks, which are “hooks” in which we can place our own code. (or modify the existing one). In addition, plugins and themes also have their own.

Given such a large number of hooks, tools like hookr help us to have a library of hooks to locate them quickly. We even now have a plugin that helps us visually see them in real time.

If you want to know more about the exciting world of hooks, I recommend you do the , in which you will see exactly how it works. The essential step to go from being a .

Loading Facebook Comments ...
Loading Disqus Comments ...