WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#31680 closed enhancement (duplicate)

get_queried_object on multiple taxonomies

Reported by: thomask Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1.1
Component: Query Keywords:
Focuses: Cc:

Description

When i use get_queried_object (or WP_Query->queried_object) with queriing multiple taxonomies, it returns only one. E.g. when i do
/?brand=tefal&product_line=pan
queried_object return only brand taxonomy, not the product_line taxonomy
WP_Query->query returns both of them
this is bit similar to this ticket: https://core.trac.wordpress.org/ticket/5358 but it is only about multiple terms in one taxonomy, not multiple taxonomies and from unknown reasons it was several times postponed.
I guess that the solution will be the same, so introducing the get_queried_objects, i just think that in this case we should change also the get_queried_object function to simply select the first (filtered option) object from the global queried_objects, so we could maintain only one query, not two. and also if multiple taxonomies (or terms) are queried, wp should by default return their intersection and sums (by default intersection for combination of taxonomies+terms as in this example, and sum for queries with multiple terms, e.g. brand=tefal+rowenta)

Change History (1)

#1 @boonebgorges
6 years ago

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

Duplicate of #5358.

if multiple taxonomies (or terms) are queried, wp should by default return their intersection and sums (by default intersection for combination of taxonomies+terms as in this example, and sum for queries with multiple terms, e.g. brand=tefal+rowenta)

This is an interesting idea, which can already be accomplished by passing a complex 'tax_query' parameter. I don't think it's directly related to your suggestion about get_queried_object().

this is bit similar to this ticket: https://core.trac.wordpress.org/ticket/5358 but it is only about multiple terms in one taxonomy, not multiple taxonomies

Yes, but the underlying issue (and as you note, the solution) is the same in both cases. Let's move discussion over there.

Note: See TracTickets for help on using tickets.