Questions tagged [tax-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
1k views

How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?

I need to search property post types, in a regular WP_Query that is not the main query, but I need to be able to search for a value LIKE in any of the following meta_queries and also need to search ...
0
votes
1answer
352 views

Wordpress tax_query ignoring relation OR

Yo guys, I am writing related posts method and I am trying to get all posts that have one or more terms in one or more taxonomies. Here is the sample of what my function spits out: array( '...
1
vote
1answer
478 views

List taxonomy / category count showing list published posts only

I want to show on a list of taxonomy with corresponding posts counts of published items only. Checking the WP documentation, It seems I can ALMOST achieve that by using the get_terms function https://...
1
vote
1answer
890 views

Hidden woocommerce products still showing up in search results

I'm really new to php editing but I'm trying to learn. My woocommerce products that are set to "hidden" under catalog visibility are still showing up under search results. How do I keep hidden ...
1
vote
1answer
244 views

Querying on multiple taxonomies pulled from $_GET checkbox array not working?

I'll keep this super concise the normal search works perfectly, but when I've added some checkboxes for additional features, etc…the tax_query doesn't work however I know the $_GET is working as I've ...
0
votes
1answer
471 views

Optimal way to make tags in tax_query optional?

Is there a more elegant way of doing this same thing. I have three filters that I want to use to effect the results in the fourth field. The pool, month, and tags are the filters. I want the tags ...
0
votes
1answer
748 views

Is it possible to add relation between meta_query and tax_query?

I have custom post type with some ACF fields. I use ACF for extra properties of entity, and I use native wordpress taxonomies too for base category of entity. So I need to build query with meta_query ...
0
votes
3answers
510 views

WP Query tax_query not returning posts

I have a WP query that searches for any custom posts under type 'tribe_events' tagged as 'featured' under the taxonomy 'tribe_events_cat'. So, just to be clear: post_type = 'tribe_events' taxonomy = '...
0
votes
1answer
1k views

tax_query (if the terms are empty)

I'm confused, what do I pass in order to get all posts from all terms? Right now I can for instance pass featured in order to get all events, but how do I get all events? I know I could just get rid ...
1
vote
1answer
312 views

Custom Widget WP_Query problem

I have everything working on my widget except the results! I created a taxonomy called country names that we use for several custom post types. I created this widget to display tour guides (CPT) from ...
0
votes
0answers
1k views

Combine tax_query and meta_query in WP_Query

I'm building a search in WordPress. I look for a custom_post_type in combination with several custom taxonomys and metadatas. custom_post_type: vehicle taxonomys: brand, fueltype, ... metadata: ...
0
votes
1answer
78 views

Complex Taxonomy scheme

We are building a resorts site and we're facing a huge taxonomy problem. On one side, we have administrative locations such as country>>region>>department and "natural" locations, such as mountain-...
1
vote
1answer
29 views

How do I display the grand child items of a taxonomy term?

I am trying to display the grand child terms for a custom taxonomy term. The main parent taxonomy term is product_range, the child taxonomy term is Mechanical Trackballs, each child category has ...
0
votes
1answer
144 views

Not able to get my custom search result using meta_query and tax_query together?

I created a custom search where i am able to show the Fields (ACF fields) and also Taxonomies. But while I am searching by taking the combination of both Taxonomies and meta fields, i am not getting ...
2
votes
1answer
1k views

How do I sort posts by custom taxonomy?

I am trying to sort posts by custom taxonomy. I have a custom post type which is course-cpt and I have created custom taxonomies within it, I need to sort the courses by course-level (which is the ...
1
vote
2answers
924 views

WP_Query, tax_query and term_meta: How to?

I have a custom post type product (wine). Each of the following is a custom taxonomy: Vintage (Year of harvesting) [only one per wine] Family (Grape variety) [may be more than one] Size (Bottle Size) ...
0
votes
1answer
127 views

in tax_query this Is the code correct? I need to access beginner video posts for different subject

$args = array( 'post_type' => 'videolesson', 'ordeby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 8, '...
0
votes
1answer
3k views

tax_query: Order by slug?

Long story short, I inherited a Wordpress site at work and I have an events page that I'm working on/fixing. I'm new to both Wordpress and php and I could use some help. Each event is categorized by ...
0
votes
1answer
57 views

First ID won't be excluded in wp_dropdown_pages with an $arg from tax_query

I'm having trouble to exclude specific posts in wp_dropdown_pages. Exclude seems to work, but the first ID of my foreach is ever and ever include in the dropdown... I don't understand why... My ...
0
votes
0answers
76 views

Error get_posts with Custom Taxonomy and OR relation

I've been stuck on this for hours... I did a var_dump($list_items) right before if ( $list_items ) { and it turns up empty, but a var_dump($hold_tax_query) looks (to me) like it should. if($...
0
votes
0answers
328 views

How to display just video post format?

I actually stuck to display a 'video' post format in the video section on main page. Here is my current code: <?php // The Query $query = new WP_Query( array( ...
0
votes
2answers
285 views

No results found for second level category

I am trying to retrieve posts from a category. I have 2 level and 3 level category hierarchy. I am using tax query in pre get posts filter to alter the query. The query works fine for the first ...
-1
votes
1answer
835 views

Output ACF field dynamicaly within a taxonomy loop [closed]

So I have this block that loops over my taxonomies and loads a template file to display each one of them while in it: <?php $collections = get_terms( 'resource-collection', array( 'orderby' ...
0
votes
1answer
2k views

Is it possible to dynamically get queried term AND taxonomy?

I'm not sure if this is possible but I'm trying to get my taxonomy.php file to work the same for all 10 of my custom taxonomies. The code below works exactly as I need it to (ie: when at a url ending ....
0
votes
1answer
1k views

Custom tax_query filter not working for Woocommerce product categories

For some reason using pre_get_posts isn't filtering the products properly on the Shop page. I can tell the hook is being called on the proper page because if I print the $query variable it only shows ...
2
votes
1answer
4k views

The Operator “NOT IN” Does Not Work In tax_query

I'm trying to alter the search functionality of a WooCommerce store so when a user makes a query that matches a product_tag slug it returns the products that don't have that product tag assigned. The ...
0
votes
1answer
244 views

Count number of posts which exist in 2 taxonomies?

I know I can use something like this to count for ONE tax: $catcount=get_term_by('slug','apple', 'FRUIT'); echo $catcount->count; but not sure how to count posts that are in combos between ...
1
vote
0answers
2k views

How can I hide uncategorized products from search results?

I'm trying to hide products that are not in any category (product_cat) from the search results. I've been trying to figure out how I could modify the search query to exclude these products, but I can'...
0
votes
2answers
298 views

Parse error: syntax error, unexpected ''tax_query'' in wordpress

hi i want to display posts by term. first the code display all the posts: $aProjectArgs = array( 'post_type' => 'uni_project', 'posts_per_page' => -1, '...
2
votes
2answers
14k views

Tax_query terms ID's using variable

I want to make a custom WP_Query using custom taxonomy terms ID´s. Example of the term’s ID’s : 19,18,214,226,20 Why does this work: $query_args = array ( 'post_type' => 'works’, '...
0
votes
1answer
893 views

display all posts from category with and without terms in chronological order

Under a category "fruits" I have posts with terms "apples", "oranges" and without any terms but in that category. How do I display all posts from the category "fruits", including posts that have ...
0
votes
1answer
721 views

Create alphabetical Pagination for custom taxonomy?

I want to create an alphabetical pagination for terms from custom taxonomy so I'll be displaying it like this: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z So for example if I click on the ...
0
votes
1answer
173 views

In Product Category archives how to show Posts having same/similar prod_cat slug structure?

I will be writing Posts about each of Product's Product Categories (product_cat on products) and I am choosing to group (associate) Posts by the product_cat hierarchical taxonomy. To do this without ...
1
vote
0answers
250 views

Custom Taxonomy Not Working When added to WordPress Search

I have created custom taxonomies for a custom post type. I have added drop downs to the search form so I can add the custom taxonomies to the search criteria. The problem I am having is that when my ...
2
votes
1answer
955 views

tax_query shows no results if nothing is selected

I am creating a real estate website on WordPress, I am creating a custom search and am using tax_query to filter search results to display "States" & "Suburbs". The search works fine, when ...
1
vote
1answer
1k views

WooCommerce: filter by parent product's taxonomy and product variation's meta data

In WooCommerce, I would like to filter my products page based on product variation's meta and related variable products's taxonomy. Note: All products have variations, there's no product without ...
0
votes
1answer
199 views

WordPress Multiple Taxonomy Query

I've a simple form made up of two multiple selects which (as if by magic) filters my posts archive with URL parameters: <form class="filters"> <select name="country" multiple> ...
0
votes
1answer
29 views

modifying main query to query for ranges e.g. from 1999 to 2016

I've taxonomy _year and I'm modifying main query by hooking into pre_get_posts action. My code looks like this: if ( ! empty( $_GET['mt-from-year'] ) ) { $from_year = ...
1
vote
1answer
976 views

WP_Query tax_query on ACF post_object

I have a custom post type Wine, which has an ACF Field that links to another custom post type Producer as a post_object relation. In my Producer, I have a custom taxonomy named Region. Now, what I'm ...
0
votes
4answers
5k views

Use both meta query and tax query

I would like to use both the meta_query and the tax_query, but using the following I can get results for the meta_query. What am I doing wrong? $wp_query = new WP_Query( array( 'post_type'...
0
votes
1answer
92 views

How to show post which has the specific taxonomy terms?

I am very new to coding.The following code is working fine which shows the post which has taxonomy "persons", but when I am using second part then it is not showing the content.What I want is to show ...
0
votes
1answer
537 views

Using get_posts, I need to use a combination of OR & AND relations

Using WordPress v4.6, I set up arguments for get_posts() based on price (2 conditions), sku, and categories like this: [meta_query] => Array ( [relation] => AND [0] => ...
0
votes
1answer
26 views

How can I get all the posts that are related with a specific taxonomy term?

I'm using the technique below for that (getting all the post related with a taxonomy term), but for some reason if I have some posts with the term e and post with the term English I get them all and ...
7
votes
1answer
8k views

Wordpress tax_query “and” operator not functioning as desired

I have a custom post type of image with a custom taxonomy called image_tag (it's hierarchical like categories). Here are some examples of the tags that might be used: Structure (id: 25) - House (id: ...
1
vote
1answer
2k views

How to write a Tax Query that matches all terms in an array?

I'm creating a product filter, and I've been struggling trying to figure out how to get this query to work properly. I need to be able to feed this query an array of terms (woocommerce product ...
0
votes
1answer
937 views

Woocommerce orderby rand with tax_query not random

I would like to change the related products section on my woocommerce products details page so it only displays related child category products (not products that only have the parent category in ...
0
votes
0answers
182 views

How to combine nested tax_query logic with other nested query logic?

I use multiple custom taxonomies for my site and have successfully implemented a custom search which allows nesting of tax_query logic. However I now want to update that to include an option on ...
0
votes
1answer
638 views

Custom taxonomy and query multi conditions

I have this query $query->set( 'tax_query', array( 'relation' => 'OR', array( 'taxonomy' => 'location', ...
1
vote
1answer
537 views

Populate tax_query terms parameter with post term

I need to populate the terms parameter in my tax_query with the current term of the post. I have been trying to use the WP function wp_get_post_terms in a variable and then referencing that variable ...
4
votes
3answers
14k views

Get term by custom term meta and taxonomy

How to get term by custom term meta and taxonomy or how to filter tax_query by term meta instead slug/id? function custom_pre_get_posts($query) { global $wp_query; if ( !is_admin() &&...