Any product category with slug Downloads won't show in the shop sidebar
authorLaury GvR <laury@gaslightmedia.com>
Wed, 17 May 2017 21:07:27 +0000 (17:07 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 17 May 2017 21:07:27 +0000 (17:07 -0400)
parts/shop-cats-and-products.php

index 6414057..5258c8f 100644 (file)
@@ -1,46 +1,48 @@
-<?php 
+<?php
     $args = '';
     $product_categories = get_terms( 'product_cat', $args );
     $count = count($product_categories);
     if ( $count > 0 ){?>
         <div class="categories">
         <?php foreach ( $product_categories as $product_category ) {
-            $args = array(
-                'posts_per_page' => -1,
-                'tax_query' => array(
-                    'relation' => 'AND',
-                    array(
-                        'taxonomy' => 'product_cat',
-                        'field' => 'slug',
-                        // 'terms' => 'white-wines'
-                        'terms' => $product_category->slug
-                    )
-                ),
-                'post_type' => 'product',
-                'orderby' => 'title,'
-            );
-            $products = new WP_Query( $args );
-            if ($products->have_posts()) { ?>
-                        <div class="category-container">
-                            <?php 
-                            echo '<div class="category-title">';
-                            echo '<a href="' . get_term_link( $product_category ) . '">' . $product_category->name . '</a>';
-                            echo '</div>';
-                            echo "<ul class='category-products'>";
-
-//                            while ( $products->have_posts() ) {
-//
-//                                $products->the_post();
-                                ?>
-<!--                                    <li class="product">
-                                        <a href="<?php // the_permalink(); ?>">
-                                            <?php // the_title(); ?>
-                                        </a>
-                                    </li>-->
+            if ($product_category->slug !== "downloads") {
+                $args = array(
+                    'posts_per_page' => -1,
+                    'tax_query' => array(
+                        'relation' => 'AND',
+                        array(
+                            'taxonomy' => 'product_cat',
+                            'field' => 'slug',
+                            // 'terms' => 'white-wines'
+                            'terms' => $product_category->slug
+                        )
+                    ),
+                    'post_type' => 'product',
+                    'orderby' => 'title'
+                );
+                $products = new WP_Query( $args );
+                if ($products->have_posts()) { ?>
+                            <div class="category-container">
                                 <?php
-//                            }
-                            echo "</ul>";?>
-                        </div>
+                                echo '<div class="category-title">';
+                                echo '<a href="' . get_term_link( $product_category ) . '">' . $product_category->name . '</a>';
+                                echo '</div>';
+                                echo "<ul class='category-products'>";
+
+    //                            while ( $products->have_posts() ) {
+    //
+    //                                $products->the_post();
+                                    ?>
+    <!--                                    <li class="product">
+                                            <a href="<?php // the_permalink(); ?>">
+                                                <?php // the_title(); ?>
+                                            </a>
+                                        </li>-->
+                                    <?php
+    //                            }
+                                echo "</ul>";?>
+                            </div>
+                <?php } ?>
             <?php } ?>
         <?php } ?>
         </div>