Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [tax-query]

The tag has no usage guidance.

73 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
2k views

Display related products with custom output

I'm trying to display the related products with my custom html output, unfortunately i'm kind of lost on how to do this. The WP_Query below displays the products that are in stock, what i want is to ...
2
votes
0answers
56 views

Can't make a tax_query across different post types

I am attempting to build a tax_query, and I'm unable to make it behave. What I want to retrieve from the query are two different content types: A) Posts that are in a specific Category B) Portfolio ...
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 ...
2
votes
0answers
846 views

tax_query OR with empty result returns all posts

I'm running a WP_Query with a tax_query with two tax_query statements with an OR relationship. $tax_query_terms = array( array('taxonomy' => 'post_tag', ...
1
vote
0answers
14 views

Searching in title or meta, with a tax query too!

As suggested in WP Query Args - Title or Meta Value I tried to query my Custom Content Type on Title and Meta Value alternatively. It almost works, but only if I do not introduce a tax query (and I ...
1
vote
1answer
83 views

Change default ordering of taxonomy terms - pre_get_terms

I wanted to change the default taxonomy terms order by its 'term_order' value instead of 'name' in admin side. So I tried something like below. But it doesn't work and php memory exhaust. function ...
1
vote
0answers
22 views

?cat=-1 Indexed Versions Of Homepage

I'm finding some strange query strings on my homepage are indexed in Google and causing duplicate content. A couple of examples: https://sciencetrends.com/page/103/?cat=-1 https://sciencetrends.com/?...
1
vote
0answers
37 views

Taxonomy Query Relation field not behaving correctly?

This is my post entries with categories and tags I am using Taxonomy query When I use relation AND - Tax Query for Category Geed + Tag Cool Nothing shows up. But When I use relation OR 2 The post ...
1
vote
0answers
40 views

Tax Query for custom Taxonomy field

I have a stock filter on WooCommerce shop page. So I need to filter number of products based on the selection from the user for this filter. I have variable products and I am not able to control ...
1
vote
0answers
125 views

Tax query in pre_get_posts not working

I'm trying to filter the main query on the home.php template so I only shows posts from the latest issue taxonomy. What I have so far is the below but it is still showing all the posts on the ...
1
vote
0answers
72 views

Why is this query not working? (Standard posts + custom post type)

I'm trying to figure out why this query is not working, as it seems like it should be very straightforward. Basically, I'm querying for both standard posts of certain categories (and excluding another)...
1
vote
0answers
503 views

Using meta_query and tax_query at the same time

I’ve got the following query on my page template: $args = array( 'post_type' => 'givingback', 'post_status' => 'publish', 'posts_per_page' => 100, '...
1
vote
1answer
46 views

Retrieve Custom Taxonomies according to posts selected

I have 3 custom taxonomies. The first 2 are for car make and model, the 3rd is for car series. The goal is make a widget which lists car series' depending on current post (make and model). function ...
1
vote
0answers
193 views

WP_Query with tax_query, order by most 'matches'

TL;DR: How can I sort a WP_Query based on how many 'matches' there are on the tax_query set. Furthermore, how can I then add more posts if the posts_per_page is not met due to the tax_query added? ...
1
vote
0answers
52 views

Terms with more than one occurrence have current-menu-item class in menu

I have a lot of taxonomies and I am using one term (from any of the taxonomies) in more than one place in my menu. I want to implement a post loop which depends on the menu id and all its parent ids. ...
1
vote
0answers
53 views

More then one menu items are assigned with “current-menu-item” class

I am new with WordPress so apologize if i am doing this in a wrong way. I have lot of taxonomies and posts types. I am using one term (from any of the taxonomy) in more then one places in my menu but ...
1
vote
1answer
362 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 ...
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'...
1
vote
0answers
253 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 ...
1
vote
0answers
170 views

Wordpress tax_query not showing private posts

When querying posts with the following: $getClientsArgs = array( 'post_type' => 'client', 'showposts' => -1 ); query_posts($getClientsArgs); Private posts are displayed if the person ...
1
vote
1answer
409 views

Hiding taxonomies with no children WP_Query & tax_query

I have this code which has taken over 7 hours to put together through research but the last hours or so I have hit a brick wall! I require the taxonomy title to be hidden if there are no posts ...
1
vote
0answers
86 views

Exclude posts which have any term in a certain taxonomy from the query

I have a custom taxonomy, and for a certain query I am doing, I want to retrieve all posts which do not have any terms of that taxonomy assigned (for example, they are tag-less). At the beginning I ...
1
vote
2answers
747 views

How to create a WP_Query to search the Title or Tag?

I have created a search using WP_Query, it seems like this query is looking for the queried term in title AND tags. Is there a way to have this search the title OR tags? $s = $request['s']; $tags = ...
0
votes
0answers
13 views

AND relation in tax_query now working

I want to apply filters on 'retailers' custom post type. Filters are on the basis on following taxonomies. Shipping Type Release Type Raffles I am using AJAX to apply filters. (https://savior.d....
0
votes
0answers
14 views

Query Multiple meta key values

I have a custom post type with 4 custom fields Participant (ayp_user) Event (ayp_event) Category (ayp_category) Total Score (ayp_score) I have set the following meta_query in a query. But it is ...
0
votes
1answer
39 views

list all post who have mutual taxonomy as current taxonomy!

I have app archive site with two different taxonomy type: Seller and Kind, I want to have a page for every seller and inside that page, I want to have multiple lists for every term of "Kind" taxonomy. ...
0
votes
1answer
75 views

Why pagination is not working with tax_query param?

this is my query: $p_query = new WP_Query(array( 'post_type' => $post_type ,'post_status' => 'publish' ,'posts_per_page' => $per_page // 6 ,'paged' => $page // 2 ,'...
0
votes
0answers
440 views

Woocommerce change tax rate programmaticly

We sell a combination of multiple products as one product, these products can't be added separte to WordPress so we use a normal product type for the combination. These products have seperate tax ...
0
votes
0answers
36 views

WordPress post_status and meta_query

I created a custom post status and I would like to set auto-change (clients are filling two dates, precomming and ongoing). How can I do auto-post-status change when it is after precomming or ongoing ...
0
votes
1answer
86 views

WP Query Conditionally query meta and taxonomy

I develop a plugin which includes a custom post type that is displayed as a list within WP Admin. There are varying levels of users defined within the plugin and a few other options which determine ...
0
votes
0answers
19 views

how to display post of lowest terms - ancestors wise?

I want to achieve 3 post display from each taxonomy terms. But this terms will be passed from lowest of hierarchy in array that is ('munnar','cochin') etc. Europe Asia - India -- Kerala --- Munnar ---...
0
votes
1answer
184 views

How to set `tax_query` with `query->set()`

While this works: $query->set( 'post__not_in', array( 30140, 30020, 30008, 29998, 29991, 21458, 20197, 11986, 6614 ) ); This doesn't: $tax_query = array( 'taxonomy' => 'filter', 'terms' ...
0
votes
0answers
122 views

posts_per_page in a tax_query

I want to show two latest posts of a taxonomy in a front_page.php template. $args_article = array( 'post_type' => ['text'], 'post_status' => ['publish'], '...
0
votes
1answer
33 views

Custom search for a custom post type in WordPress

I have created a custom search for a custom post type in WordPress that searches car vehicles. I can search by manufacturer and model but I want the search to be flexible and show results based on any ...
0
votes
1answer
361 views

Find all product that contain terms with %keywords% in WP_Query

I want to use WP_Query to find all product terms entered in the input field. Here is my WP_Query code. $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( '...
0
votes
0answers
53 views

Tax_Query not working - connecting to second wordpress database

I'm trying to run a WP_Query - using a second database, the connection and results work just fine until I use tax_query and then no results are returned: <?php $wpdb_backup = $wpdb; $wpdb =...
0
votes
0answers
48 views

tax_query not working?

tax_query is not working, inside the eachloop I'm trying to echo $use_case_category->slug; and getting all the taxonomies on the screen and not the ones selected by bootstrap tabs. All the rest of ...
0
votes
1answer
186 views

Order Wordpress Query by Custom Field While Still Using Tax_query Argument

Currently, I have a query that searches for all employees with a taxonomy term that matches the word that is searched for in an input field. That works perfectly fine but my client now wants the ...
0
votes
1answer
861 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
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-...
0
votes
1answer
175 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 ...
0
votes
1answer
133 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
0answers
84 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
375 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
292 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 ...
0
votes
2answers
337 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, '...
0
votes
1answer
219 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 ...
0
votes
1answer
225 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
574 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] => ...