From de89edd699638359e9df106bd867bf157f57c615 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 24 Sep 2013 17:09:56 +0000 Subject: [PATCH] When is_main_query() is called during the pre_get_posts hook, issue _doing_it_wrong(). The is_main_query() WP_Query method should be used in these instances instead. see #23329. git-svn-id: https://develop.svn.wordpress.org/trunk@25605 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/query.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wp-includes/query.php b/src/wp-includes/query.php index c1ed984837..c2615cd0ab 100644 --- a/src/wp-includes/query.php +++ b/src/wp-includes/query.php @@ -717,6 +717,12 @@ function is_404() { * @return bool */ function is_main_query() { + if ( 'pre_get_posts' === current_filter() ) { + $message = sprintf( __( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ), + 'pre_get_posts', 'WP_Query::is_main_query()', 'is_main_query()', __( 'http://codex.wordpress.org/Function_Reference/is_main_query' ) ); + _doing_it_wrong( __FUNCTION__, $message, '3.7' ); + } + global $wp_query; return $wp_query->is_main_query(); }