Skip to content

Instantly share code, notes, and snippets.

@hmbashar
Created February 6, 2019 01:50
Show Gist options
  • Save hmbashar/f9c7100fb93690e86d87f16baebe64a3 to your computer and use it in GitHub Desktop.
Save hmbashar/f9c7100fb93690e86d87f16baebe64a3 to your computer and use it in GitHub Desktop.
show categories with sub categories list before product on shop page
// show categories with sub categories list before product on shop page
function understrap_woocommerce_before_shop_loop() {
echo '<ul class="product-cats">';
woocommerce_output_product_categories();
echo '</ul>';
$term_id = get_queried_object()->term_id;
if($term_id) {
echo '<ul class="product-cats">';
woocommerce_output_product_categories(array(
'parent_id' => $term_id,
));
echo '</ul>';
}
}
add_action('woocommerce_before_shop_loop', 'understrap_woocommerce_before_shop_loop', 8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment