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

---

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

## In this article

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

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

Checks if a specific callback has been registered for this hook.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_hook/has_filter/?output_format=md#description)󠁿

When using the `$callback` argument, this function may return a non-boolean value
that evaluates to false (e.g. 0), so use the `===` operator for testing the return
value.

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

 `$hook_name`stringoptional

The name of the filter hook. Default empty.

`$callback`callable|string|array|falseoptional

The callback to check for.
 This method can be called unconditionally to speculatively
check a callback that may or may not exist.

Default:`false`

`$priority`int|falseoptional

The specific priority at which to check for the callback.

Default:`false`

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

 bool|int If `$callback` is omitted, returns boolean for whether the hook has anything
registered. When checking a specific function, the priority of that hook is returned,
or false if the function is not attached.
 If `$callback` and `$priority` are both
provided, a boolean is returned for whether the specific function is registered 
at that priority.

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

    ```php
    public function has_filter( $hook_name = '', $callback = false, $priority = false ) {
    	if ( false === $callback ) {
    		return $this->has_filters();
    	}

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

    	if ( ! $function_key ) {
    		return false;
    	}

    	if ( is_int( $priority ) ) {
    		return isset( $this->callbacks[ $priority ][ $function_key ] );
    	}

    	foreach ( $this->callbacks as $callback_priority => $callbacks ) {
    		if ( isset( $callbacks[ $function_key ] ) ) {
    			return $callback_priority;
    		}
    	}

    	return false;
    }
    ```

[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#L240)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-hook.php#L240-L262)

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

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

Checks if any callbacks have been registered for this hook.

  | 
| [_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/has_filter/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Added the `$priority` parameter. | 
| [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%2Fhas_filter%2F)
before being able to contribute a note or feedback.