Title: WP_Hook::apply_filters
Published: December 6, 2016
Last modified: May 20, 2026

---

# WP_Hook::apply_filters( mixed $value, array $args ): mixed

## In this article

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

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

Calls the callback functions that have been added to a filter hook.

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

 `$value`mixedrequired

The value to filter.

`$args`arrayrequired

Additional parameters to pass to the callback functions.
 This array is expected
to include $value at index 0.

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

 mixed The filtered value after all hooked functions are applied to it.

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

    ```php
    public function apply_filters( $value, $args ) {
    	if ( ! $this->callbacks ) {
    		return $value;
    	}

    	$nesting_level = $this->nesting_level++;

    	$this->iterations[ $nesting_level ] = $this->priorities;

    	$num_args = count( $args );

    	do {
    		$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );

    		$priority = $this->current_priority[ $nesting_level ];

    		foreach ( $this->callbacks[ $priority ] as $the_ ) {
    			if ( ! $this->doing_action ) {
    				$args[0] = $value;
    			}

    			// Avoid the array_slice() if possible.
    			if ( 0 === $the_['accepted_args'] ) {
    				$value = call_user_func( $the_['function'] );
    			} elseif ( $the_['accepted_args'] >= $num_args ) {
    				$value = call_user_func_array( $the_['function'], $args );
    			} else {
    				$value = call_user_func_array( $the_['function'], array_slice( $args, 0, $the_['accepted_args'] ) );
    			}
    		}
    	} while ( false !== next( $this->iterations[ $nesting_level ] ) );

    	unset( $this->iterations[ $nesting_level ] );
    	unset( $this->current_priority[ $nesting_level ] );

    	--$this->nesting_level;

    	return $value;
    }
    ```

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

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

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

Calls the callback functions that have been added to an action hook.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_hook/apply_filters/?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%2Fapply_filters%2F)
before being able to contribute a note or feedback.