WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/has filter

Contents

Description

Check if any filter has been registered for a hook.

Usage

 <?php has_filter$tag$function_to_check ); ?> 

Parameters

$tag
(string) (required) The name of the filter hook.
Default: None
$function_to_check
(callback) (optional) If specified, return the priority of that function on this hook or false if not attached.
Default: False

Return

int|boolean 
Optionally returns the priority on that hook for the specified function.

Examples

<?php
if ( ! has_filter'the_content''example_alter_the_content' ) )
    
add_filter'the_content''prefix_alter_the_content' );
?>

Notes

  • Uses: global array $wp_filter that stores all of the filters

Change Log

  • Since: 2.5.0

Source File

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

Related

Filters: has_filter(), add_filter(), apply_filters(), current_filter(), merge_filters(), remove_filter(), remove_all_filters()

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