Action hook 'loop_no_results'

in WP Core File wp-includes/class-wp-query.php at line 3848

View Source

loop_no_results

Action Hook
Description
Fires if no results are found in a post query.

Hook Information

File Location wp-includes/class-wp-query.php View on GitHub
Hook Type Action
Line Number 3848

Hook Parameters

Type Name Description
WP_Query $query The WP_Query instance.

Usage Examples

Basic Usage
<?php
// Hook into loop_no_results
add_action('loop_no_results', 'my_custom_function', 10, 1);

function my_custom_function($query) {
    // Your custom code here
}

Source Code Context

wp-includes/class-wp-query.php:3848 - How this hook is used in WordPress core
<?php
3843  			 *
3844  			 * @since 4.9.0
3845  			 *
3846  			 * @param WP_Query $query The WP_Query instance.
3847  			 */
3848  			do_action( 'loop_no_results', $this );
3849  		}
3850  
3851  		$this->in_the_loop = false;
3852  		return false;
3853  	}

PHP Documentation

<?php
/**
			 * Fires if no results are found in a post query.
			 *
			 * @since 4.9.0
			 *
			 * @param WP_Query $query The WP_Query instance.
			 */
Quick Info
  • Hook Type: Action
  • Parameters: 1
  • File: wp-includes/class-wp-query.php
Related Hooks

Related hooks will be displayed here in future updates.