Questions tagged [tax-query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

SQL Query - custom tax_query not working when querying two taxonomies

I have a created a custom table in my WP database called wp_opportunities which stores locations with their lat and long. I'm trying to query the table based on the taxonomy term set on the post ID ...
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 ...
0
votes
0answers
17 views

Get taxonomy terms used in posts that have second taxonomy with specific term

I'm not sure I know how to phrase this question best, so please bear with me. I have a custom post type (artworks) which has two custom taxonomies attached (artist eg. name, and media eg. painting ...
0
votes
0answers
21 views

Related posts ordered by taxonomy

On my single post page, I display 4 related posts based on 3 custom taxonomies products, artists, and product-category. Everything works fine with the code below. BUT: Right now, with this code, the ...
0
votes
0answers
27 views

wp_query with meta_query and tax_query

I am trying to find a way to combine a meta_query and a term_query and i got confused with the research. $sport = 'basket'; $args_p = array( 'posts_per_page' => 10,...
0
votes
1answer
17 views

WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

This is really confusing me. I've tried numerous things but cannot get appropriate results. Here's what I currently have for my query: $args = array( 'post_type' => 'product', 'tax_query'...
0
votes
1answer
10 views

How to search through all child taxonomies using WP_Query?

I need to create a page in which I can search through child taxonomies(custom child-category) based on GET request (For example $_GET['search_cat']) using WP_QUERY. I just want to list all of the sub-...
0
votes
0answers
16 views

Taxonomy query instead of category_name and such

I'm a bit stumped and was hoping for some insight. I'm just learning to code and am trying to modify a plugin (WP Loop) from referencing category_name and category__not_in to referencing a custom ...
0
votes
1answer
17 views

exclude product with available tag

I have classic WP_Querry: $products = new WP_Query( $args ); with $args = [ 'post_type' => 'product', 'posts_per_page' => 500, 'product_cat' => 'cars', ]; If I want products ...
0
votes
1answer
773 views

tax_query showing no results

I'm creating a music database site with two custom post types: tracks and albums. I've linked the tracks to their respective albums with a custom taxonomy for the album's slug. On each album page, I'm ...
1
vote
1answer
476 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 ...
0
votes
0answers
18 views

Why does this wp_query fail to show posts when 'category_not_in' is removed?

I'm trying to figure out this wp_query function for a site where a user can configure what posts are displayed on their page. This site pulls in blog feeds from other external blogs and has categories ...
2
votes
2answers
1k 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 = ...
1
vote
0answers
20 views

Is it a good idea to improve meta query performance by adding tax query?

I'm aware that using taxonomies over metadata is preferred when it comes to posts grouping. In simple words this and this are saying "use meta for unique data and taxonomy for repeating data(the one ...
1
vote
4answers
10k views

Wordpress tax query use operator LIKE

I have taxonomy color which is associated with a custom post type. I am listing all the post meta and the taxonomy in a table. I have a option in the table to search the posts matching the search ...
1
vote
1answer
46 views

Custom post taxonomies as tax_query terms?

I have these two custom post types called “product” and “reference”. On “references” I have attached a custom taxonomy called “product_reference” which I use to specify which products the references ...
0
votes
1answer
658 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
2answers
512 views

Extending WP Query: Custom geolocation meta values work, but tax_query breaks

I've built a custom query for geolocation searches. I'm saving lat and lng within each custom post type as a meta value. My query extension returns results successfully when lat and lng are the only ...
0
votes
1answer
593 views

Get the tax term in which is a post via wp_query

I'll rewrite my original question because I feel like I can't be understood : I made a template page on which I have different WP_Query. I have a category taxonomy (countries). This template page ...
0
votes
1answer
28 views

How to add tax_query to $args with concatenation

I am trying to make a feed arguments into a wordpress loop conditionally, and hence want to add to arguments based on tags, categories or attributes provided by a filter system. I can't seem to work ...
0
votes
1answer
51 views

get_posts( $args ) return empty data

I'm writing plugin for syncing prices of WooCommerce products with external source. So I want to get products with EAN (have meta data _wpm_gtin_code). Whaterver I pass to get_posts($args) I get empty ...
0
votes
1answer
40 views

simple tax_query intersection

I'm trying to do tax_query for posts that have a term1 in taxonomy1 AND a term2 in taxonomy2 if I do: 'tax_query' => [ 'relation' => 'AND', [ 'taxonomy' => 'taxonomy1', '...
0
votes
1answer
41 views

WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank

I have created a rather complex WP_Query, I need to restrict the arguments that are used within the query dependant on the users inputs. I appreciate I can wrap the whole argument in an IF statement, ...
0
votes
1answer
32 views

Set both meta_query and tax_query using wp_query->set

Is there a way to combine both tax_queries and meta_queries using wp_query->set() ? I am trying to create an AJAX filter for WooCommerce, and I'm currently building out the conditional wp_query->set(...
1
vote
0answers
26 views

WP_Query | Tax_Query Relation | Unable to use 'OR' as it then allows all products, help me finish my query?

I began slightly baffled and have slowly degraded to slightly going insane as I am building this wp_query. Admittedly it is a very complex query and there is a lot of additional code that has brought ...
0
votes
1answer
1k 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 ...
21
votes
3answers
54k views

Nested meta_query with multiple relation keys

I am curious whether Wordpress is able to run nested meta_query, with each having different relation keys? As of Wordpress 3.0, tax_query is able to perform this function; I'm wondering whether this ...
2
votes
3answers
3k views

search query within custom taxonomy term, post title and meta field

I want to create a search that does: Search within my custom taxonomy - custom-tags search the post title search select meta field ?? dont know search with custom post type - easy part I looked ...
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 ...
0
votes
0answers
27 views

tax_query and sort by meta_key - no results

I have query: $tax_query = array( 'relation' => 'AND'); $tax_query[] = array( 'taxonomy' => 'kategoria', 'field' => 'id', 'terms' => $term->...
0
votes
1answer
689 views

Custom taxonomy and query multi conditions

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

Tax-query on taxonomy doesn´t work

I am trying to get out a custom posttypes that belongs to a specific taxonomy. I don't get it sorted out on taxonomy, it takes every custom post. I use this code global $post; $terms = get_terms('...
0
votes
2answers
143 views

Get category if used in a custom post type

I'm trying to get a list of categories if they are used in a Custom Post type. The post type uses the default categories taxonomy. There are also other custom post types that use the same default WP ...
0
votes
1answer
926 views

Custom arguments in WP_Query

I am working on a Wordpress theme i.e. Directory engine. It is having a filtering functionality in the header based on taxonomy term slug. I just want to know from where this tax_query is generated ...
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 ...
5
votes
3answers
6k views

When tax_query used, results disappear (0 =1 produced)

I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post_type, and displays results accordingly — A user makes a selection from 3 drop-downs on a form, each have a ...
0
votes
1answer
26 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
49 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
70 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 ...
1
vote
1answer
801 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
169 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
76 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
73 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
77 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
16 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
26 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
2k views

Tax query AND/OR meta query [duplicate]

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 ...
20
votes
1answer
95k views

“tax_query” parameter not working with WP_Query

I have a custom post type called 'episode'. Attached to 'episode' I have a custom taxonomy called 'video_type' that contains two terms: "bonus-footage" and "episode"; "episode" contains two child ...
0
votes
1answer
2k views

Get pages only with a specific taxonomy

I added a custom taxonomy called 'post_tag' to the pages, and I am trying to make a query that gets only the pages that have a specific tag set. I already tried in several different ways, even using ...
3
votes
2answers
278 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
2 3 4 5