[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
Thu Nov 2 04:33:30 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 | Resolution:
Keywords: close | Focuses:
--------------------------+------------------------------
Changes (by dd32):
* keywords: => close
Comment:
Ignoring requests for `p=0` seems like the expected behaviour to me, it's
not a valid value for the parameter and thus isn't a single/singular
request.
If you wish to avoid the default WP_Query query, you can use the
`posts_pre_query` filter (see #36687) - code below isn't tested
{{{
add_filter( 'posts_pre_query', function( $val, $wp_query ) {
if ( $wp_query->is_main_query() ) {
return false; // any non-null value will cancel the request. Can
also return an array of Post objects.
}
return $val;
}, 10, 2 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42398#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list