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(); }