return $cols;
}
-/* Exclude Category from Shop*/
-add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
-function get_subcategory_terms( $terms, $taxonomies, $args ) {
- $new_terms = array();
-
- // if a product category and on the shop page
- if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
- foreach ( $terms as $key => $term ) {
- if ( ! in_array( $term->slug, array( 'downloads' ) ) ) {
- $new_terms[] = $term;
- }
- }
- $terms = $new_terms;
+// Remove category slug from woocommerce shop
+add_action( 'pre_get_posts', 'remove_cat_from_shop_loop' );
+
+function remove_cat_from_shop_loop( $q ) {
+
+ if ( ! $q->is_main_query() ) return;
+ if ( ! $q->is_post_type_archive() ) return;
+
+ if ( ! is_admin() && is_shop() ) {
+
+ $q->set( 'tax_query', array(array(
+ 'taxonomy' => 'product_cat',
+ 'field' => 'slug',
+ 'terms' => array( 'downloads' ), // Change it to the slug you want to hide
+ 'operator' => 'NOT IN'
+ )));
+
}
- return $terms;
+ remove_action( 'pre_get_posts', 'remove_cat_from_shop_loop' );
+
}
?>
$output .= "\n<li>\n";
$output .= "\n<div class=\"shop-drop\">\n";
$output .= "\n<h1>Trail Maps & Guidebooks</h1>\n";
- $output .= "\n<a class=\"button\" href=\"" . get_permalink( woocommerce_get_page_id( 'shop' ) ) . "\">Shop Now</a>\n";
+ $output .= "\n<a class=\"button\" href=\"" . get_permalink( wc_get_page_id( 'shop' ) ) . "\">Shop Now</a>\n";
$output .="\n</div>\n";
$output .="\n</li>\n";
}
-<?php
+<?php
global $woocommerce;
-?>
+?>
<div class="shop-sidebar">
<div class="page_item page_item_has_children">
- <a href="<?php echo get_permalink( woocommerce_get_page_id( 'shop' ) ); ?>">
+ <a href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?>">
Categories
</a>
</div>
Checkout
</a>
</div>
- <?php
+ <?php
$myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' );
- if ( $myaccount_page_id ) {
+ if ( $myaccount_page_id ) {
$myaccount_page_url = get_permalink( $myaccount_page_id );
?>
<div class="page_item page_item_has_children">
<h4>Shop Our Trail Maps & Guidebooks</h4>
<img class="right" src="<?php echo bloginfo('template_url'); ?>/assets/the-trails-of-m-22-book.png">
<p>Need a good trail map or a guidebook to what lies beyond the pavement? Check out our shop stocked with our latest backpacking maps and books personally autographed by the authors who wrote them! It's the best and most affordable way to purchase maps and trail books to Michigan.</p>
- <a class="button" href="<?php echo get_permalink( woocommerce_get_page_id( 'shop' ) ); ?> ">Shop Now</a>
+ <a class="button" href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?> ">Shop Now</a>
</div>
<div class="small-12 large-5 columns">
<div class="blog">