Posted in WordPress

Definition of a WordPress hook

Hooks.

The term confused me for ages when I first started looking into WordPress plugin development. Anything I’ve learned about them I feel like I’ve done despite rather than because of the tutorials I consulted about them. Feeling like you’ve missed something can really undermine the learning process and chip away at the satisfaction you feel about doing things right.

So it’s nice to read an article whose author notes specifically that the term is often used incorrectly and confusingly to refer to two different things:

Just as in pop-music, the term “hook” is sometimes ambiguous—different people use the term to refer to different things. Technically, the term “hook” should refer to a WordPress event, such as get_header or the_content, but sometimes it is used generally to refer to the add_action() or add_filter() functions which reference the hook. Pay attention to the context, and it should be clear which meaning was intended. The most important thing to understand here is that you determine when your functions execute by attaching them to a WordPress event by using the add_action() or add_filter() functions. Remember: hooks are events.

From Anatomy of a WordPress Plugin, which incidentally is all quite well-explained.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s