Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [tax-query]

The tag has no usage guidance.

-1
votes
1answer
11 views

How to pass >= condition filter to my year custom tax_query

I have a custom taxonomy called year. I need to filter posts by pre_get_posts tax_query from year value to to year value. I am searching from one hour now feeling stuck. Please guide me. Thank you
2
votes
1answer
40 views

get complex results set according to category structure

I need to get a complex result set from a WordPress database according to the category structure. First I will try to explain my category structure. I have three level structure as bellow. flight [...
0
votes
1answer
41 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
2answers
21 views

get_terms with posts that have a different taxonomy with term x

Here's the situation; I am using get_terms to retrieve all terms from Tax 1 with posts associated with it. Using the following $args = array( 'hide_empty' => 0, '...
0
votes
1answer
52 views

How to display Related Posts based on number of taxonomy terms matched

I have a custom post-type 'News' which has multiple custom taxonomies 'news-category', 'news-tags'. Each post contains between 4-8 'news-tags' and 1 'news-category'. For my current post, I'd like to ...
1
vote
2answers
231 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
16 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
70 views

Query child posts with tax query on parents

I have this WP_Query: new WP_Query( array( 'post_type' => 'product_variation', 'post_status' =&...
0
votes
1answer
66 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
1answer
39 views

Custom Category Walker with Image, Fallback to Most Recent Post in Category Image

Based on this and this answer I am developing an extension of the Walker_Category which displays in image from an ACF field, falling back to the latest post's thumbnail. I have included the entire ...
0
votes
0answers
84 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
30 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
47 views

Nested tax_query that allows specified categories OR tags, but NOT other categories

I'm trying to create a nested tax query that does the following: Exclude posts that have any of several specified category IDs. AND include posts that have any of several other specified category IDs,...
0
votes
1answer
237 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
1answer
81 views

Get posts in taxonomy randomly

I am having a query like this Code 1 $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $args = array( 'post_type' => 'l', 'post_status' ...
0
votes
0answers
25 views

All sticky posts are displaying on home.php and ignoring tax_query

I'm trying to query the main loop on my home.php template to display posts which are only in a specific taxonomy 'issue-41'. I'm using the pre_get_posts function to achieve this but when testing it, ...
0
votes
0answers
94 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 ...
0
votes
2answers
37 views

Loop posts based on permalink term

I have setup my custom post's custom taxonomy's permalink structure to be: custom post type > custom taxonomy > post (from this helpful Q&A) Now I'm hoping to be able to code taxonomy.php to ...
4
votes
1answer
371 views

pre_get_posts with tax_query causes empty result

I need to adjust the main loop for all archive pages in the following way. I have registered a custom taxonomy "myposttypes". Every single post is assigned to exactly one term of "myposttypes". If it ...
0
votes
2answers
134 views

How can I add multiple 'tax_query' arrays via a loop?

I'm trying to build functionality (using the Advanced Custom Fields plugin) to list information in a page template for all custom post types ('Product') that have specified taxonomies. This is my ...
1
vote
1answer
148 views

How to combine tax_query and date_query in Wordpress

I'm using the following query to extract all products which are not in the 'Service' product category and order them by a custom meta field '_vintage_age'. $q->set( 'tax_query', array(array( '...
1
vote
0answers
62 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)...
0
votes
0answers
60 views

wp_get_post_terms() not returning values for logged out users

I've encountered an issue where wp_get_post_terms() is returning values for logged in users only, but not logged out users (incognito window, other browser, etc). I'm trying to get the values from ...
0
votes
1answer
151 views

Custom taxonomy query not working with switch_to_blog

Whats the wrong with this query? $args = array( 'category__not_in' => 1, 'post_status' => 'publish', 'numberposts' => 1, 'tax_query' => array( array( ...
0
votes
1answer
35 views

How can I get the last 5 element of this tax query?

$args = array( 'post_type' => 'news', 'posts_per_page' => 5, 'post_status' => 'publish', 'order' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'week', '...
0
votes
0answers
49 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
33 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 ...
1
vote
0answers
351 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
41 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
1answer
1k 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 ...
0
votes
2answers
34 views

Finding WordPress Posts assigned to multiple categories

I have a site with around 8000 products, with a slightly poor site structure - instead of custom taxonomies the Brand Name and Retailer are Parent Categories with the various individual brands, and ...
0
votes
1answer
30 views

Getting Custom Posts with Custom Taxonomy

I am trying to get the custom posts "contact" with the custom taxonomy "abteilung" for this post type. Everything i am trying is not working. Now i am stuck with the following. The problem is, that ...
1
vote
1answer
1k views

Tax query AND/OR meta query

In my WP_Query I'd like to have a tax query and a meta query, but I want the results to include results that match the tax query AND/OR the meta query - if I do it like the below, then it only returns ...
2
votes
0answers
30 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 ...
0
votes
1answer
126 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 ...
1
vote
0answers
167 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
1answer
590 views

pre_get_posts Remove tax_query if $_GET['tax']==all

I'm using pre_get_posts to filter by using $wp_query->set( 'tax_query', $tax_query ); I'm probably better-off doing this with a new WP_Query, but if someone knows something I don't I'd love to ...
1
vote
1answer
79 views

Get taxonomy parent using child slug (from merged taxonomies)

So, I tried a bunch of ways to do this, but none worked. I have an array, that has a lot of values from different taxonomies (from the same custom post type), I'm giving an example with only 2, but ...
0
votes
1answer
52 views

Secondary WP_Query being overriden in archive page

I'm running into a particular problem with an archive page. This particular page is supposed to list all post that belong to a category, but is able to be filtered by a second (custom) taxonomy: i.e.: ...
1
vote
0answers
47 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
48 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
177 views

Tax_query not working on multisite

This query was working fine, but now i'm having a trouble with it since i've switched to multisite. I've added "global $switched" and "switch_to_blog(4)", and it works fine when i remove the "...
0
votes
1answer
935 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
316 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
405 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
760 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
212 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
420 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
625 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
418 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 = '...