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/current filter

Contents

Description

Retrieve the name of the current filter or action.

Usage

<?php current_filter(); ?>

Parameters

None.

Return Values

(string) 
Hook name of the current filter or action.

Examples

Get the current filter:

function my_filter() {

    echo current_filter(); // 'the_content'
}
add_filter( 'the_content', 'my_filter' );

Get the current action:

function my_init_function() {

    echo current_filter(); // 'init'
}
add_action( 'init', 'my_init_function' );

See also this example from toscho at WordPress Answers.

Notes

  • Uses global: (unknown type) $wp_current_filter

Change Log

Since: 2.5

Source File

current_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.