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

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -