Take all produts by category

category_name is for category taxonomy, sense products use the product_cat you will need to add a tax_query into $args. Like this. $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 20, ‘tax_query’ => [ ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘name’, ‘terms’ => ‘trofee’, ], ‘meta_query’ => array( ‘relation’ => ‘OR’, array( // Simple products type ‘key’ … Read more

Group and list posts by custom taxonomy

I re-factored your code, there were quite some parts which seemed overly complex or used deprecated methods. In the code below, I’m looping through your terms, and within that loop, I’m finding the posts relating to that term. Probably there’s a more efficient way, since this is using several queries, but it should achieve the … Read more