2

New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at tutorials/guides, they say "simply add this function to the wp_head action or after_setup_theme". Without these tutorials, how on earth would i know to hook that function to that action?

As a beginner, how the heck would i know what is the appropriate action to hook on to? Any advice on how to navigate this? Thanks

2

Take a look at Mike's answer to a similar question more specifically the plugin he posted there can be used to create a list of all action hooks and filters that were called to generate that page in order of execution.

6

The best way to learn the most important filters is to read the source code. Whenever you want to change the output of a function read its source. Then you’ll either find the hook in this function or in another function called by the first. In some cases there is no hook and you have to hack … but that’s the next level.

There are some tools to inspect hooks, and you will write your own probably sooner or later. But nothing beats reading the source.

  • And as a quick tip to others coming across this... here's what I do: I keep a mirror of the Wordpress git repository on my machine, and when I want to find a hook... fire up a command prompt and git grep till I get what I want – Tim Malone Apr 15 '16 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.