Questions tagged [tax-query]
The tax-query tag has no summary.
274 questions
0 votes
0 answers
12 views
Taxclass based on certain conditions: location+userrole
I have a Woocommerce store, all my prices are incl. tax. Its a b2c/b2b hybrid store. I need the following: Only certain user role (wholesale) AND only outside of NL should have a certain taxclass. The ...
0 votes
1 answer
88 views
Adding a language rule and displaying posts with a custom taxonomy term on its archive page
The WordPress website I'm working on is available in two languages using Polylang, en-US and en-PH. I use CPT UI and have a custom taxonomy "subtopic" that is not multilingual. Under "...
0 votes
2 answers
669 views
Querying by post category slug with core/query block markup
I know how to query all posts in a certain category by slug with WP_Query. What I would like to do is the same with the core/query block markup. I am able to get it working with the category ID, but I'...
1 vote
0 answers
24 views
Same query args showing different results order when setting different number of posts
This query using the same arguments is returning different posts order: sample / test codes: // Query 1 $query_args = [ 'post_type' => 'business', 'showposts' => 8, 'no_found_rows' =&...
0 votes
1 answer
136 views
Operator 'AND' in the get_posts() function's tax_query terms not working
I am trying to get posts that are present in both the taxonomy terms. This is the code that didn't work: $args = array( 'post_type' => 'workshops', 'posts_per_page' => -1, 'fields' =...
2 votes
1 answer
1k views
Custom query with custom filtering returning incorrect results
I've setup a custom query, I'm using Woocommerce and I am aware that it has it's own functionality, but have been tasked with creating custom filtering with a traditionally paged product/category ...
0 votes
1 answer
308 views
wp_get_object_terms count on taxonomies within an category archive
Working on a category archive, i have a sidebar with custom non hierarchical taxonomies, used as filters (like custom post_tags). In order to list those filters, I use wp_get_object_terms: <?php ...
0 votes
0 answers
353 views
Custom Query: Multiple CPTs and a taxonomy filter
I want to create a post feed that displays the following: ALL posts in the CPT 'custom_post_type_1' Any 'post's in the category 'speakers' So far, I have this filter which displays all posts in '...
1 vote
1 answer
1k views
Order WP_Query by The Order of an Array in Tax_Query
I have a wp_query that uses tax_query to which I pass an array of taxonomy term IDs. I'd like to order my results based on the order of that array but can't get it to work and searching has got me ...
0 votes
0 answers
130 views
Any quicker alternative for WP_Query "NOT IN"
I am using the following wp_query to pull up a list of post, and I want to exclude a few categories of a custom taxonomy. It works well, however Query Monitor is telling me that the query is slow. I ...
0 votes
0 answers
1k views
Tax Query on product_cat using NOT IN as operator does not exclude that category
Using the following code, I expect $items to not include products with the product category "stones." However, that is not the result. It doesn't seem to be excluding that category at all. ...
1 vote
2 answers
1k views
Override tax_query with pre_get_posts to include other term_ids on a single category
I'm trying to include more than one term_id(multiple checkboxes filter) on a single category page. I managed to recollect enough to build a tax_query with pre_get_posts, but now it seems, I have two ...
3 votes
1 answer
638 views
Fastest way of counting posts of a custom post type in a specific taxonomy term?
I know this kind of question is legion but I have read through all related topics and I can't find a satisfying solution. What I want to achieve is simple: on my taxonomy (author) term archive page I ...
0 votes
1 answer
448 views
Tax Query only returns for the first of several terms
I'm trying to query a customer post type where the results may be within one of several associated terms. The issue however is that only the first term yellow-gold-jewellery is being returned for, and ...
0 votes
1 answer
614 views
How To Query For An Empty Taxonomy Field
I want to write a query that looks up taxonomies. One condition is that taxonomyA returns x, and a second condition is that taxonomyB returns empty. I don't know how to query for empty. This is what ...