filter custom post query by taxonomy
-
Hi i’m basically trying to edit the featured-product widget that comes with Woocommerce to filter results by the product category taxonomy.
Either by ID or by Slug.
I think this is the query that pulls the featured products, but i’m unable to find any documentation that could help me filter by categories.
<?php $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product' ); $query_args['meta_query'] = array(); $query_args['meta_query'][] = array( 'key' => '_featured', 'value' => 'yes' ); $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $r = new WP_Query($query_args); if ($r->have_posts()) : ?>Any help would be amazing, thanks in advance
The topic ‘filter custom post query by taxonomy’ is closed to new replies.