Introduce loop_no_results
action.
This action fires when a `WP_Query` query returns no results. Props mgibbs189. Props #40850. git-svn-id: https://develop.svn.wordpress.org/trunk@40923 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c321e10c16
commit
bb0354dda1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user