Introduce `loop_no_results` action.

This action fires when a `WP_Query` query returns no results.

Props mgibbs189.
Props #40850.
Built from https://develop.svn.wordpress.org/trunk@40923


git-svn-id: http://core.svn.wordpress.org/trunk@40773 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2017-06-23 01:55:44 +00:00
parent 3a6985de96
commit 8951af8ebb
2 changed files with 10 additions and 1 deletions

View File

@ -3144,6 +3144,15 @@ class WP_Query {
do_action_ref_array( 'loop_end', array( &$this ) );
// Do some cleaning up after the loop
$this->rewind_posts();
} elseif ( 0 === $this->post_count ) {
/**
* Fires if no results are found in a post query.
*
* @since 4.9.0
*
* @param WP_Query $this The WP_Query instance.
*/
do_action( 'loop_no_results', $this );
}
$this->in_the_loop = false;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-40922';
$wp_version = '4.9-alpha-40923';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.