Have you ever wondered why WordPress is the most used CMS (Content Management System) in the web?

The answer may rely on its flexibility and variety of plugins and themes available; anyone can build a new website with less development effort and knowledge and equip it in seconds with e-commerce, mailing and other functionality; all this thanks to its hooks.

What is hook?

Hooks are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress. [site]

WordPress offers two types of hooks, action hooks (which are executed at specific points when WordPress is loaded) and filter hooks (which are used to replace or modify values in WordPress).

What is the difference between both?

Code wise, both are executed at specific points when WordPress is loaded, so the real difference is that one (filters) returns a value and the other do not. In a quote:

Filters return a value and actions do not.

Which is better to use?

Will depend on what needs to be accomplished when using them.