Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickgregory/64cf3ce91b441d2a9ca4408b6e5554e8 to your computer and use it in GitHub Desktop.
Save rickgregory/64cf3ce91b441d2a9ca4408b6e5554e8 to your computer and use it in GitHub Desktop.
Code to allow Breakdance Product List widget to show only product in the current category
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term ) {
$product_cat_id = $term->term_id;
$product_cat_name = $term->name;
}
return ['post_type'=>'product','tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $product_cat_name,
),
)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment