Title: WP_Hook::remove_filter
Published: December 6, 2016
Last modified: February 24, 2026

---

# WP_Hook::remove_filter( string $hook_name, callable|string|array $callback, int $priority ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#wp--skip-link--target)

Removes a callback function from a filter hook.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#parameters)󠁿

 `$hook_name`stringrequired

The filter hook to which the function to be removed is hooked.

`$callback`callable|string|arrayrequired

The callback to be removed from running when the filter is applied.
 This method
can be called unconditionally to speculatively remove a callback that may or may
not exist.

`$priority`intrequired

The exact priority used when adding the original filter callback.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#return)󠁿

 bool Whether the callback existed before it was removed.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#source)󠁿

    ```php
    public function remove_filter( $hook_name, $callback, $priority ) {
    	if ( null === $priority ) {
    		$priority = 0;
    	}

    	$function_key = _wp_filter_build_unique_id( $hook_name, $callback, $priority );

    	$exists = isset( $function_key, $this->callbacks[ $priority ][ $function_key ] );

    	if ( $exists ) {
    		unset( $this->callbacks[ $priority ][ $function_key ] );

    		if ( ! $this->callbacks[ $priority ] ) {
    			unset( $this->callbacks[ $priority ] );

    			$this->priorities = array_keys( $this->callbacks );

    			if ( $this->nesting_level > 0 ) {
    				$this->resort_active_iterations();
    			}
    		}
    	}

    	return $exists;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-hook.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-hook.php#L193)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-hook.php#L193-L217)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Hook::resort_active_iterations()](https://developer.wordpress.org/reference/classes/wp_hook/resort_active_iterations/)`wp-includes/class-wp-hook.php` |

Handles resetting callback priority keys mid-iteration.

  | 
| [_wp_filter_build_unique_id()](https://developer.wordpress.org/reference/functions/_wp_filter_build_unique_id/)`wp-includes/plugin.php` |

Builds a unique string ID for a hook callback function.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_hook/remove_filter/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_hook%2Fremove_filter%2F)
before being able to contribute a note or feedback.