From: Laury GvR Date: Tue, 23 May 2017 13:49:36 +0000 (-0400) Subject: Same as last commit, also replaced woocommerce_get_shop_id with wc_get_page_id as... X-Git-Tag: v1.0.0^2~67 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=257a693e6a60e7585c3376df2514b60bcef02673;p=WP-Themes%2Fmichigantrailmaps.git Same as last commit, also replaced woocommerce_get_shop_id with wc_get_page_id as per WooCommerce recommendations --- diff --git a/functions.php b/functions.php index 63cd93c..3e515e7 100644 --- a/functions.php +++ b/functions.php @@ -304,22 +304,27 @@ function new_loop_shop_per_page( $cols ) { 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' ); + } ?> diff --git a/lib/menu-walker.php b/lib/menu-walker.php index 4e1f7a4..cc9cfee 100644 --- a/lib/menu-walker.php +++ b/lib/menu-walker.php @@ -50,7 +50,7 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu { $output .= "\n
  • \n"; $output .= "\n
    \n"; $output .= "\n

    Trail Maps & Guidebooks

    \n"; - $output .= "\nShop Now\n"; + $output .= "\nShop Now\n"; $output .="\n
    \n"; $output .="\n
  • \n"; } diff --git a/parts/shop-sidebar.php b/parts/shop-sidebar.php index 3ee7ce5..de792a4 100644 --- a/parts/shop-sidebar.php +++ b/parts/shop-sidebar.php @@ -1,9 +1,9 @@ - +?>
    @@ -18,9 +18,9 @@ Checkout
    -
    diff --git a/sections/front-page.php b/sections/front-page.php index 0cea148..16299b8 100644 --- a/sections/front-page.php +++ b/sections/front-page.php @@ -11,7 +11,7 @@

    Shop Our Trail Maps & Guidebooks

    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.

    - Shop Now + Shop Now