From 8951af8ebbe872798452e3551675a6706f8631a5 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 23 Jun 2017 01:55:44 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-query.php | 9 +++++++++ wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php index e20d574409..a578f9afc7 100644 --- a/wp-includes/class-wp-query.php +++ b/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; diff --git a/wp-includes/version.php b/wp-includes/version.php index f78effa21d..001172f72b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.