You’re missing the tax_query
key, and it needs to be a nested array:
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'terms' => $cat_id,
'field' => 'term_id',
),
),
);
Check the documentation
Related Posts:
- Custom archive page based on array of categories and tags
- tax_query shows no results if nothing is selected
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Custom taxonomy.php not working
- get all posts associated with a custom taxonomy
- list all post who have mutual taxonomy as current taxonomy!
- Taxonomy archive, categorised by other taxonomy, not hiding empty taxonomies
- Taxonomy Terms That Don’t Exist Display Results
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- How to add taxonomy filter on the query fly?
- Display posts the match taxonomy term linked from wp_list_categoies?
- WP_query taxonomy + get all posts with two terms from same taxonomy
- SQL Statement generated by WP_Query not producing expected results
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Filter and list posts of a custom taxonomy
- WP_Query use for a filter with multiple Taxonomies and Terms
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Improving WP_Query performance for multiple taxonomies
- get complex results set according to category structure
- How to Modify Taxonomy Archive Page with Search Parameter?
- Get array of current post term ID’s
- Paginated Taxonomy Term Archive including one post per term
- Setup of taxonomy term template pages
- Get image of latest post from taxonomies/categories
- Display link to taxonomy archive only if it has posts with certain custom field values
- How to do a query on custom taxonomies that is uncategorised?
- WP_Query, tax_query and term_meta: How to?
- Order taxonomy terms in alphabetical order
- Advanced Query Logic With Multiple Taxonomies
- Function get_queried_object() return NULL in custom taxonomy
- Getting Taxonomy inside WP_Query Loop
- Order posts by taxonomy count
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Query custom post type by custom taxonomy (category slug)
- WP_Query ignoring tax_query when is_singular
- How do I exclude the lowest level terms in a taxonomy?
- wp_query for multiple cities (multiple values in a metabox)
- How to display an other custom post type in a different custom post type’s archive?
- Search form not working with custom query?
- Post loop for all taxonomy terms
- wp_query args adding muitiple tax_querys
- Query most popular terms by taxonomy over 2 week period
- find posts that don’t have a custom taxonomy
- Filter Custom Taxonomy Posts
- WP_Query args to show posts from specific custom taxonomy
- How to set an alternate posts_per_page value for default queries in different templates
- How to add custom meta to ‘pre_get_terms’?
- Tax Query only returns for the first of several terms
- Can’t fetch Custom Post Type Data through Custom Query
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- One WP_Query that always shows 1 post from category X and 1 post from “not in category X”?
- How to print term name inside wp post loop
- Check if a post has term inside loop
- How to get posts by category and by choosing a taxonomy term?
- How to restrict search on a certain page to only return results against custom taxonomies?
- Query Taxonomy By Page Title
- Custom Taxonomy Breaks Pages
- check if a taxnomy queried in $wp_query?
- WP_Query tax_query – Show results if child has parent X
- Query custom taxonomy for category including children
- get_the_terms has strange result since version 6.0
- How to display posts from custom post type category(custom Taxonomy) wise?
- Why is my pagination /page/2 taking me to index.php?
- Filter for each loop when WP_Query has no posts to show
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- How do I stop the same post showing multiple times in a archive?
- wp_query with meta_query and tax_query
- Related categories order posts by category
- WordPress – Form does not filter the results of taxonomies
- WP Query for all events prior to current date
- How to get taxonomy image attached to a Post Type WordPress
- Why pagination is not working with tax_query param?
- Show one post of each custom taxonomy
- Displaying posts from sub taxonomies only
- Optimal way to make tags in tax_query optional?
- How to define a custom hierarchy for terms?
- My entry results are not consistently alphabetized
- Combine Tax Archive and Meta_Query in WP_Query
- Adding additional taxonomies to wordpress taxonomy page
- I cannot get tax_query in get_posts() to work with custom taxonomy
- In Product Category archives how to show Posts having same/similar prod_cat slug structure?
- Query Top Set Custom Taxonomy In Given Timeperiod
- Object of class WP_Query could not be converted to int inside shortcode
- Rewrite rule pagination on different url levels
- Custom query for tag and custom tag from 2 post type
- How to get hierarchical number of custom taxanomy
- Get newest value of an array
- Filter custom post type by custom taxomony
- List posts of terms but exclude one term
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- Query posts filter not working
- Storing/querying custom date data
- Multiple loops on a Search result page?
- query_posts problem – need help
- WP_Query and DES sort for Custom Taxonomy based upon a meta field?
- Output ACF field dynamicaly within a taxonomy loop [closed]
- Incorrect taxonomy ID assigned to post with custom query
- Custom Taxonomy in custom REST API search
- taxonomy-{term}.php terms pagination returning 404 after a certain page