Don't show WooCommerce shop categories if there are none
authorLaury GvR <laury@gaslightmedia.com>
Mon, 21 Nov 2016 19:11:25 +0000 (14:11 -0500)
committerLaury GvR <laury@gaslightmedia.com>
Mon, 21 Nov 2016 19:11:25 +0000 (14:11 -0500)
parts/shop-cats-and-products.php
parts/shop-sidebar.php

index 4906022..6414057 100644 (file)
@@ -2,8 +2,9 @@
     $args = '';
     $product_categories = get_terms( 'product_cat', $args );
     $count = count($product_categories);
-    if ( $count > 0 ){
-        foreach ( $product_categories as $product_category ) {
+    if ( $count > 0 ){?>
+        <div class="categories">
+        <?php foreach ( $product_categories as $product_category ) {
             $args = array(
                 'posts_per_page' => -1,
                 'tax_query' => array(
@@ -42,4 +43,5 @@
                         </div>
             <?php } ?>
         <?php } ?>
+        </div>
     <?php } ?>
\ No newline at end of file
index 099429f..3ee7ce5 100644 (file)
@@ -7,9 +7,7 @@
             Categories
         </a>
     </div>
-    <div class="categories">
-        <?php echo get_template_part("parts/shop-cats-and-products"); ?>
-    </div>
+    <?php echo get_template_part("parts/shop-cats-and-products"); ?>
     <div class="page_item page_item_has_children">
         <a href="<?php echo $woocommerce->cart->get_cart_url(); ?>">
             Cart