WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If a plugin modified one of wp's filters by "add_filter", and I want to discard the modification and modify the wp's filter by my own codes. Should I remove the plugin's filter before I add my own filter?

share|improve this question
To replace a filter you should use remove_filter first – tamilsweet Jun 6 '12 at 0:28
up vote 2 down vote accepted

Yes, you need to remove it first and then add your one. You can do it by calling remove_filter function like this:

remove_filter( 'wp_core_filter_hook', 'wp_core_filter_hook_handler', 10 );

Pay attention at third parameter passed to function: it is priority, it should be the same as defined when the function was originally hooked, otherwise the filter hook won't be removed.

If you want to remove all hook handlers, you can call remove_all_filters function:

remove_all_filter( 'wp_core_filter_hook' );
// or with priority
remove_all_filter( 'wp_core_filter_hook', 10 );

This function takes two parameters: filter name and priority (optional). If you pass priority then all handlers with specified priority will be removed.

And finally if you want to check if any filter has been registered for a hook, use function has_filter. It takes two parameters: filter name and function name (optional).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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