In WP_Query how to query ID’s as an OR with a category as the other criteria
-
Hi, I am working on a woocommerce site and I am writing a query with WP_Query I am looking to query products that either belong in this array of post id’s OR if as part of the same category as the product, and I’m not sure how to complete this tax_query. Any ideas?
$args = array( 'post_type' => 'product', 'posts_per_page' => 4, // 'post__in' => $cross_upsells, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'product_cat', 'field' => 'slug', //This is optional, as it defaults to 'term_id' 'terms' => $category_slug, 'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'. ), ), );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘In WP_Query how to query ID’s as an OR with a category as the other criteria’ is closed to new replies.