wordpress - Query / Filter woocommerce products by product type -
i added new product type here
now want show product type. here query:
$query_args = array('post_type' => 'product' ); $r = new wp_query( $query_args ); if ( $r->have_posts() ) { .........
how can query products of new product type?
in woocommerce, "post type" custom taxonomy, need add taxonomy parameters wp_query
.
$query_args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => 'your_type', ), ), );
where terms
argument same in $this->product_type = 'your_type';
part of new product type's class constructor.
Comments
Post a Comment