A Beginners Guide to WordPress Hooks Aussie Developer If you are already in WordPress plugin development or theme development, then you should already know what WordPress “Hooks” are. However, as you have found this post, I’m assuming that you have a brief idea about it. Here is the thing: Even if you are a beginner in “WordPress”, or a Professional, you should get yourself familiar with the term “Hook”. Interestingly, whether Knowingly and unknowingly, every WordPress theme or plugin developer are found working on WordPress hooks. As a proud WordPress user, I can say that WP has really made the life of developers easy. If you understand PHP and wp query, you can easily modify the behavior of a plugin or a theme. So, what is this hook all about? Well, hook allows us to make those prominent changes to your theme and plugins. Hooks allow you to modify WordPress functionality without editing the core files as they hook the custom function to an existing function.
Knowing the Term “HOOKS” Generally, a hook in WordPress is certain location where you can add your own code and run it, absolutely without modifying the core files. Hooks have a great ability to provide extendibility and this is the reason why they exist. You can use hooks whenever you want to customise, extend or modify the existing functionality or even create a new one without touching the core files. Hence, just like the word, “hook” does the act of hooking your code up to the core code of WordPress. For example, if I want to add a widget that allows users to easily choose social profiles to link themselves, I can write such widget as a plugin. And then, add it in our WordPress without having to worry about losing the changes the very next time we upgrade our WordPress core files. Isn’t it great? This is what makes hook more powerful and loved by developers.
Types of WordPress Hooks WordPress hooks are of two types: Action Hooks and Filter Hooks. You can execute your own code with the help of action hook whereas, a filter hook lets you change a value and return it in a