Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/remove filter


This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute. See also remove_action(), add_filter() and add_action().

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.


<?php remove_filter$tag$function_to_remove$priority ); ?>


(string) (required) The action hook to which the function to be removed is hooked.
Default: None
(callback) (required) The callback for the function which should be removed.
Default: None
(int) (optional) The priority of the function (as defined when the function was originally hooked).
Default: 10


Whether the function is removed.
  • True - The function was successfully removed.
  • False - The function could not be removed.


remove_filter( 'the_content', 'wpautop' );
foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $hook )
    remove_filter( $hook, 'capital_P_dangit' );

If a filter has been added from within a class, for example by a plugin, removing it will require accessing the class variable.

global $my_class;
remove_filter( 'the_content', array($my_class, 'class_filter_function') );

It is also worth noting that you may need to prioritise the removal of the filter to a hook that occurs after the filter is added. You cannot successfully remove the filter before it has been added.


When using filters passed with objects, you most often need to pass the exact same object back to the remove filter call, not just another instance of that object.(read _wp_filter_build_unique_id() for the gory details)

Change Log

  • Since: 1.2.0

Source File

remove_filter() is located in wp-includes/plugin.php.


Filter Functions:

See also index of Function Reference and index of Template Tags.