[wp-trac] [WordPress Trac] #42398: WP_Query with parameter post id 'p'=0 is not considered as a single post request
WordPress Trac
noreply at wordpress.org
Wed Nov 1 17:54:29 UTC 2017
#42398: WP_Query with parameter post id 'p'=0 is not considered as a single post
request
--------------------------+-----------------------------
Reporter: solo14000 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.7
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hi there,
I'm trying to run a 'dummy' main WP query requesting only the post ID = 0
for performance purpose (all my requests are performed using AJAX with
secondary extended WP queries)
However WP_Query does not detect a single post request adding SQL clauses
like 'LIMIT'
In the class-wp-query.php file, the PHP test to set single post is
{{{#!php
<?php
} elseif ( $qv['p'] ) {
$this->is_single = true;
}}}
that of course fails with 'p' = 0
Is that an expected behavior ?
I'm using the following code
{{{#!php
<?php
add_action('pre_get_posts', 'cb_pre_get_posts');
function cb_pre_get_posts($query){
$query->set('p', 0);
}
}}}
Thanks in advance,
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42398>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list