[wp-trac] [WordPress Trac] #36381: query_posts neglecting other parameters when 'name' is used
WordPress Trac
noreply at wordpress.org
Thu Mar 31 04:49:33 UTC 2016
#36381: query_posts neglecting other parameters when 'name' is used
-----------------------------+-----------------------------
Reporter: ioweuiraosjfosj | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.4.2
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
When using the query_posts with the 'name' parameter it will always return
the post even if the given post does not match with the other parameters.
This will return the post 'Hello World' even though its NOT in the
category.
{{{
query_posts( array ( 'category_name' => 'category', 'name' => 'hello-
world' ) );
while (have_posts()):
the_post();
get_template_part( 'content', get_post_format() );
endwhile;
}}}
This is a workaround that works:
{{{
query_posts( array ( 'name' => 'hello-world' ) );
while (have_posts()):
the_post();
if( in_category('category') ) get_template_part( 'content',
get_post_format() );
endwhile;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36381>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list