Excluding woocommerce cats by slug instead of id.
authorLaury GvR <laury@gaslightmedia.com>
Wed, 28 Jun 2017 14:31:06 +0000 (10:31 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 28 Jun 2017 14:31:06 +0000 (10:31 -0400)
Excluding the categories on the frontpage and sidebar by ID resulted
in these not being excluded on local and development copies. Using
the slug fixes this as they're all referred to as 'Whitepages'.

parts/shop-cats-and-products.php
sections/front-page.php

index 3c8e0d8..385d7ea 100644 (file)
@@ -1,11 +1,14 @@
 
 
-<?php $args = array(
+<?php
+        $excluded_cat = get_term_by( 'slug', 'whitepapers', 'product_cat' );
+        $excluded_cat_id = $excluded_cat->term_id;
+        $args = array(
          'orderby'    => 'title',
          'order'      => 'ASC',
          'hide_empty' => false,
-         'exclude'    => '18'
-       
+         'exclude'    => $excluded_cat_id
+
     );
     $product_categories = get_terms( 'product_cat', $args );
     $count = count($product_categories);
@@ -36,7 +39,7 @@
             $products = new WP_Query( $args );
             if ($products->have_posts()) { ?>
                         <div class="category-container">
-                            <?php 
+                            <?php
                             echo '<div class="category-title">';
                             echo '<a href="' . get_term_link( $product_category ) . '">' . $product_category->name . '</a>';
                             echo '</div>';
index 8e84e13..d749f22 100644 (file)
     </div>
     <div class="block-row">
         <div id="front-shop" class="block-column row small-up-1 medium-up-2 large-up-3" data-equalizer>
-        <?php $args = array(
+        <?php
+            $excluded_cat = get_term_by( 'slug', 'whitepapers', 'product_cat' );
+            $excluded_cat_id = $excluded_cat->term_id;
+            $args = array(
              'hide_empty' => false,
-             'exclude'    => '18',
+             'exclude'    => $excluded_cat_id,
              'orderby'    => 'menu_order',
              'order'      => 'ASC',
         );