Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#20267 closed defect (bug) (invalid)

Query_Posts not matching Custom Post Type, Taxonomy and Post-id values

Reported by: arena Owned by: arena
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Query Keywords: dev-feedback
Focuses: Cc:


I have created 1 custom Post Type (cpt) + 1 taxonomy (taxo) related to custom post type cpt.

i created 2 taxonomy terms (slugs : 'first_cat' & '2nd_cat')

I created a 'cpt' (id : 22) and "categorized" it to first_cat

When i do a query_posts with following arguments :

array (
"taxo" => "2nd_cat",
"post_type" => "cpt",
"p" => 22

the query_posts retrieves post 22 but should not due to taxo value !?

ps : i followed sample given in http://codex.wordpress.org/Taxonomies

Change History (2)

#1 @dd32
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Since you've specified a exact post to retrieve (via the p param (name, page_id, or pagename should also result in the same thing)), my understanding is that it doesn't use the query vars.

You'll however want to look into using the newer Tax Query: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

#2 @dd32
6 years ago

For reference, Taxonomy stuff is only used for non-singular requests; http://core.trac.wordpress.org/browser/trunk/wp-includes/query.php#L2204 specifiying a ID or name results in a singular request.

Note: See TracTickets for help on using tickets.