0

I have installed a plugin that adds stuff at the end of the content. I just want to apply my modifications to the post content before this plugin does.

In my case or otherwise, what is the earliest hook that can be used to modify post content even before the_content filters are applied?

  • 1
    what priority does it hook the_content on? you can use the same hook and just change priority to control whether yours runs before or after. – Milo Sep 22 '14 at 17:25
  • @Milo, thanks for replying, No it doesn't use priority. I tried priority 0,1,-1,etc... in my plugin and no response . . .. – Tabrez Ahmed Sep 22 '14 at 17:37
  • as you can see on the add_filter codex page, default priority is 20 if it's not specified. anything lower than 20 should run earlier, but you haven't shown us the code you have tried. – Milo Sep 22 '14 at 18:27
  • 3
    @Milo, I guess you meant 10 not 20 – birgire Sep 22 '14 at 18:55
2

When two or more filters are hooked to the same filter hook, the conflict is resolved as follows:

  1. If the filters are hooked with a priority parameter, the filter with a lowest value for the priority will be executed first. If no priority value is supplied, the default value is taken as 10.
  2. If two or more filters are hooked with the same priority, the filter that was hooked first will take priority.

Eg.

add_filter('the_content','filter_1',5);
add_filter('the_content','filter_2');
add_filter('the_content','filter_3');
add_filter('the_content','filter_4',1);

In the above example, filter_4() will be called first, followed by filter_1(). filter_2() and filter_3() have same priority ie. 10. Hence, filter_2() will be called next because sequentially, filter_2() was added before filter_3(). And of course, finally filter_3 is called.

Reference: Wordpress Codex Page.

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.