Created
February 6, 2019 01:50
-
-
Save hmbashar/f9c7100fb93690e86d87f16baebe64a3 to your computer and use it in GitHub Desktop.
show categories with sub categories list before product on shop page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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