Questions tagged [tax-query]

The tag has no usage guidance.

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

how do you pull data from two taxonomies?

I have posts loaded from taxonomy, but I'm trying to get the data of another, that's also attached to the same post. In the code below, the main focus is getting $location_slug. Knowing how to get ...
0
votes
1answer
22 views

Custom query for certain post type OR another post type with a certain category

I want to display posts that are either EITHER Post Type A OR Post Type B but ONLY if they are also in CATEGORY 1 Is that at all posible? How do I built my custom query?
0
votes
2answers
18 views

Sort by an ACF field in a tax_query

I do not find the solution which must surely be surely simple. (I'm new to WP) I have an ACF field named "partners_order". I would like to sort it in ascending order (ASC) here's what i tried <?...
1
vote
1answer
35 views

WP_Query tax query part of slug

I have problem with filtering post with tax query. I have a custom taxonomy called 'actors' and example of the slug is 'david-hasselhoff'. The problem is the post is found when I search with 'david ...
0
votes
1answer
37 views

How to print term name inside wp post loop

I have 3 different taxonomies in a custom post type. I want to print all posts with term name with them. for example: taxonomy 1 =>taxonomy=banks&post_type=creditcards taxonomy 2 =>...
0
votes
1answer
33 views

tax_query: Don’t show posts with parent term when they have a corresponding child term applied

I have a hierarchical taxonomy download-category from which I only want the posts with a parent term to show up: $downloads_parent_posts = get_posts( array( 'post_type' => 'downloads', ...
-1
votes
1answer
39 views

Woocommerce - Shipping tax class based on cart items not using the highest tax available

We have the "Shipping tax class" option on "Shipping tax class based on cart items". When I add a free tax product to the shopping cart and a 21% tax product to the shopping cart together, the total ...
0
votes
1answer
51 views

Select multiple categories with is_tax

i have a good function for exclude out of stock products from category. The problem is i want exclude for more than one category (really i want show only in one category, but i think this is the way. ...
0
votes
0answers
14 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....
1
vote
0answers
19 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 ...
3
votes
2answers
189 views

Does tax_query really beats meta_query in all situations?

Let me start saying that I know a 'tax_query' is faster than 'meta_query'. It's always recommended to use taxonomies over custom meta when filtering by custom data is required, but here I found ...
1
vote
1answer
73 views

tax_query returning all posts instead of selective posts in WP_Query

What I am trying to do Hi, in my site I have a custom post type called projects, then I have created a custom taxonomy for my projects post type called project_catagories. Now in my projects archive ...
0
votes
0answers
17 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
50 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
22 views

Cannot get to work tax_query array for terms

I'm trying to pass an array to the terms parameter. Basically, I have a 'portfolio' custom post type where I need to get all the categories and pass them to the terms in order to only show that '...
0
votes
1answer
137 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 ,'...
1
vote
1answer
178 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
26 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 ...
0
votes
1answer
26 views

$query->is_main_query() is causing query's tax_query to be ignored

I was having issues when modifying the main query hooking onto pre_get_posts as it was causing the menu to not be displayed. This the original code: else if ( isset( $_GET['category'] ) && !...
1
vote
0answers
821 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 ...
1
vote
0answers
43 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 ...
0
votes
0answers
45 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 ...
-1
votes
1answer
14 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
49 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
118 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 ...
1
vote
2answers
201 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
552 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
974 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
1answer
178 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
247 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
79 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
199 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
247 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,...
1
vote
1answer
527 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
254 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' ...
1
vote
0answers
138 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
81 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
1k 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 ...
1
vote
2answers
347 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
301 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
75 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
1answer
285 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
41 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
54 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
50 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
613 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
47 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 ...
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 ...