Languages: English • 日本語 (Add your language)
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 ); ?>
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)
remove_filter() is located in wp-includes/plugin.php
.