When two or more filters are hooked to the same filter hook, the conflict is resolved as follows:
- 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. - 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.