WordPress.org

Codex

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

Function Reference/doing filter

Description

Checks to see if a filter is currently being applied.

Usage

 <?php doing_filter($filter); ?>

Parameters

$filter 
(string) (optional) The name of the filter to check for, if omitted will check for any filter being applied

Return Values

(boolean) 
Returns true if $filter is being applied.

Example

To check whether the 'posts_results' filter is being applied you could write something similar to this:

 if(doing_filter('posts_results')){
   //Do Something Here
 }

To check if any filter is being applied you could write something like this:

 if(doing_filter()){
   //Do Something Here
 }

Sources

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

Related

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

This article is marked as in need of editing. You can help Codex by editing it.
Category:Functions