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
This commit is contained in:
Andrew Nacin 2013-09-24 17:09:56 +00:00
parent 3dbcfcdbe4
commit de89edd699

View File

@ -717,6 +717,12 @@ function is_404() {
* @return bool
*/
function is_main_query() {
if ( 'pre_get_posts' === current_filter() ) {
$message = sprintf( __( 'In <code>%1$s</code>, use the <code>%2$s</code> method, not the <code>%3$s</code> 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();
}