Questions tagged [tax-query]

The tag has no usage guidance.

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

Custom query give me 404 when paginate

in my site I have "CPT Clients" and each client has "CPT Success Stories", also I have a list of client's taxonomies, and when access to one of thees, I need to display the stories ...
1
vote
1answer
16 views

Fetch posts that match term slug first two letters (wp query)

I want to fetch all posts whos terms matched the first two letters of the search letters. For example, I have terms 8027179, 8027180, 8247180. Now I want to assign letter 80 and fetch posts attached ...
1
vote
0answers
10 views

Manipulate WP Query using a custom post type and multiple tax_query taxonomies

I'm using the template_redirect action to hook into my archive page before and after the query using $_GET params for 2 different taxonomies. One for GAME and another for MODES. The query works ...
0
votes
1answer
35 views

Sort custom post type by custom taxonomy

Im using this code to sort my custom post type by one of its custom taxonomies: <?php $valores = get_terms('valor', array('order' => 'DESC',)); foreach($valores as $valor) { ...
1
vote
1answer
21 views

Taxonomy archive showing no results

I have the file taxonomy-project.php and am trying to view results for some of my terms. I keep getting a result of NO even though I have a post applied to that particular term. taxonomy-project.php &...
0
votes
1answer
17 views

How to exclude a taxonomy from shop & search page wooCommerce?

In my wooCommerce shop, I've 2 taxonomy 1. Product Category 2. Services Category Shop page is showing up all products from both categories. I want to exclude products from SHOP & Search Results ...
0
votes
1answer
40 views

WP_Query for a taxonomy value OR a custom post type meta field

I have a custom post type 'csl_playlist_manager', and one of its meta-fields is 'available_to_all'. I also have a custom hierarchical taxonomy, 'csl_source', which identifies the owner of each ...
0
votes
0answers
10 views

How to set Load more button for custom taxonomy products using Ajax

I want to show more products for Load more button but my tax_query is not working for that particular taxonomy category. So how can I get the current taxonomy name to find the products? My Taxonomy ...
0
votes
0answers
17 views

Filter search results by post_tag if exist

I want to get posts from search results using post_tag. for example If a user input in the search form "party". First, we search if "party" exists in post_tag and show all posts ...
1
vote
1answer
34 views

How to Filter custom post type by taxonomy?

here is my code trying to make it <div class="row"> <div class="col-lg-3 col-md-12"> <div class="card"> <div class="card-body&...
0
votes
1answer
28 views

tax_query will produce nothing

I want to display custom type posts from a custom taxonomy category so I did this: $news = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'news', 'tax_query' => array( ...
0
votes
0answers
22 views

Can I create a tax query to return posts that match two slugs from same taxonomy

What I'm trying to achieve: I have a taxonomy 'module_data' which is hierarchical. What I want is to use a tax query to get all posts that match a slug in an array of slugs for terms AND also match a ...
0
votes
0answers
25 views

How to pass multiple values in a form for tax_query?

I am trying to create a form that allows users to view only specific posts. I have a custom taxonomy that has two parent categories, "Category" and "Age". The form has two filters ...
0
votes
1answer
47 views

Query with meta_query and tax_query together not working properly

I got some post in some categories { kids, man, woman } , and some ACF meta fields per country { Japan, South Korea ... }. If I query the categories with this tax_query it works perfectly: Array ( ...
0
votes
1answer
19 views

Tax query clause inside a meta query clause?

I need to run the following query via a WP_Query object: SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ...
0
votes
0answers
12 views

Can't reset tax query using ajax sorting plugin?

I have created an Ajax sorting feature that filters a custom post type "Music" and its all separated by Genres and Tags. The sorting works fine until. I deselect all options. I've tried to ...
0
votes
0answers
18 views

Is there a way I can merge a meta_query with a tax_query?

What I am trying to do is to hide all out of stock products, but a certain category I want to show even the out of stock products. Here is what I am using to get the category $tax_query[] = array( ...
0
votes
0answers
21 views

Show only posts without format in admin screen

The situation In admin screen (edit.php?post_type=post) using format selection dropdown adds a URL parameter like post_format=video. This makes the query to only look for posts with post-format-...
0
votes
0answers
15 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 ...
0
votes
0answers
22 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
68 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
27 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
12 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
36 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
21 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
21 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
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 ...
1
vote
0answers
24 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
1answer
93 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
45 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
110 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
58 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
55 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
95 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
27 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
0answers
46 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
23 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
399 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
20 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
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
144 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
160 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
510 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
165 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
118 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
117 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. ...
1
vote
0answers
68 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
409 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
776 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
1answer
70 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. ...

1
2 3 4 5