• I’d like to query products by a category ID, not slug, and also filter products that belong to more than 1 category. Something similar to WP_Query’s category__and

    This is the syntax that works:

    $args = array(
            'posts_per_page' => -1,
            'product_cat' => 'category-slug-here',
            'post_type' => 'product',
            'orderby' => 'title',
        );
    	$the_query = new WP_Query( $args );
    	// The Loop
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    		echo '' . get_the_title() . '<br /><br />';
    	}

    Is it possible to filter the product categories by ID? Can I filter products by using an AND condition so they must belong to multiple categories (without 2 loops?)

    https://www.ads-software.com/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Query Products by Category ID, and Multiple Categories’ is closed to new replies.