WordPress at Your Fingertips

__return_zero() WP 3.0.0

Simply returns 0. Helper function of WordPress. Useful for use in filters.

All such helper functions:
__return_false() — returns false.
__return_true() — returns true.
__return_empty_array() — returns an empty: array().
__return_zero() — returns the number 0.
__return_null() — returns NULL.
__return_empty_string() — returns an empty string: ''.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

1 time — 0.000001 sec (speed of light) | 50000 times — 0.00 sec (speed of light) | PHP 7.1.11, WP 4.9.7

No Hooks.


Int. 0.


__return_zero() // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore;


#1 Example of how to use function

Suppose we need return 0 in filter example_filter. Use this code:

add_filter( 'my_filter', '__return_zero' );

The same can be written in a different way:

// anonymous function (php 5.3+)
add_filter( 'my_filter', function(){ return 0; } );

// or so, with function registration 
add_filter( 'my_filter', 'my_return_function' );
function my_return_function(){
	return 0;


Since 3.0.0 Introduced.

Code of __return_zero() WP 5.8

function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
	return 0;

From tag: __return (helper functions)

More from category: Helper Functions

No comments
    Log In