You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When outputting the facets, e.g. as links, the query_vars entry in the processed facet data contains the query vars needed to generate a link to filter the results:
If you run a search and click a category, this works great. If you click a second category, it still works great. If you click a third category, the second is replaced with the third.
To fix this, we should be using $GLOBALS['wp_query']->tax_query->queries. It's important to note that union queries (?taxonomy=term1+term2) will add multiple arrays to $GLOBALS['wp_query']->tax_query->queries, whereas intersection queries (?taxonomy=term1,term2) will add multiple terms a single array entry. Here's a var_export() dump illustrating this:
In addition, it looks like we're not fully accounting for union queries when building the query var arrays in the facet data. Relevant code in core to mimic for consistency.
The text was updated successfully, but these errors were encountered:
Basic example
When outputting the facets, e.g. as links, the
query_vars
entry in the processed facet data contains the query vars needed to generate a link to filter the results:If you run a search and click a category, this works great. If you click a second category, it still works great. If you click a third category, the second is replaced with the third.
Problem and Proposed Solution
This is a problem with core, where core replaces the query var value with only the first in the list.
To fix this, we should be using
$GLOBALS['wp_query']->tax_query->queries
. It's important to note that union queries (?taxonomy=term1+term2
) will add multiple arrays to$GLOBALS['wp_query']->tax_query->queries
, whereas intersection queries (?taxonomy=term1,term2
) will add multiple terms a single array entry. Here's avar_export()
dump illustrating this:In addition, it looks like we're not fully accounting for union queries when building the query var arrays in the facet data. Relevant code in core to mimic for consistency.
The text was updated successfully, but these errors were encountered: