diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index e20d574409..a578f9afc7 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -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;