WordPress at a glance

remove_filter() WP 1.2.0

Removes a function from a specified filter hook.

This function can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute or to remove hooks that are added by plugins but interfere (conflict) with current code.

IMPORTANT: When removing a hook, the priority ($priority) must match the one that was set when the hook was created. If it does not match, you will not see any warnings about this - the function will simply return false.

  • It's impossible to remove a filter before it has been added!
  • If you want to delete a hook that was created inside a class, then you need to pass this instance of the class from which the hook was created.
Basis of: remove_action()
1 time = 0.s = speed of light | 50000 times = 0.06s = speed of light

No Hooks.


true/false. Whether the function existed before it was removed.


remove_filter( $tag, $function_to_remove, $priority );
$tag(string) (required)
The filter hook to which the function to be removed is hooked.
$function_to_remove(callable) (required)
The name of the function which should be removed.
The priority of the function.
Default: 10


#1 Remove a filter wpautop from hook the_content

remove_filter( 'the_content', 'wpautop' );

#2 Remove a filter capital_P_dangit from hooks 'the_content', 'the_title', 'comment_text'

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

#3 Remove a filter added from PHP class

If a filter has been added from within a class, removing it will require accessing the class variable:

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

To get a better grasp of removing hooks that use class method, see the description of remove_action()


  • Global. Array. $wp_filter Stores all of the filters and actions.


Since 1.2.0 Introduced.

Code of remove_filter() WP 5.5.1

function remove_filter( $tag, $function_to_remove, $priority = 10 ) {
	global $wp_filter;

	$r = false;
	if ( isset( $wp_filter[ $tag ] ) ) {
		$r = $wp_filter[ $tag ]->remove_filter( $tag, $function_to_remove, $priority );
		if ( ! $wp_filter[ $tag ]->callbacks ) {
			unset( $wp_filter[ $tag ] );

	return $r;

From tag: Filters (hooks)

More from category: Hooks (actions, filters)

vladlu 100vlad.lu
Editors: kama 100
No comments
    Log In . Register