• Resolved anotherbreed

    (@anotherbreed)


    Hi,

    I’m aware I can decide to display Categories only, Products only, or Categories and Products, from the customizer in WooCommerce.

    But I want to hide everything on that page, since I’m using a custom way to display the list of Categories.

    Searching within this forum only leads to solutions that are not optimal / that I would like to avoid (like using CSS to hide content, or hide only certain categories or products, or using external plugins).

    Any ideas on how to achieve that? Any code to add to functions.php or file to edit in my child theme? I’m surprised there’s no such simple option in the customizer in WooCommerce.

    Many thanks

Viewing 1 replies (of 1 total)
  • Thread Starter anotherbreed

    (@anotherbreed)

    Looks like I found a solution by copying the following file in my child theme:

    content-product_cat.php

    I added a condition that basically prevents the list of categories (I decided to display Categories only from the customizer in WooCommerce) from being displayed only in the Shop Page. Added some additional CSS to hide the empty Div container.
    Didn’t test what happens on Category pages that are set to show Sub-Categories before the list of products.

    Here’s how the file does look like now:

    
    <?php if ( is_shop() ): ?>
    		<style type="text/css">div#wc-column-container{display:none;}</style>
    <?php endif ?>
    
    <?php if ( !is_shop() ): ?>
    <li <?php wc_product_cat_class( '', $category ); ?>> CIAO MIAOA
    	<?php
    	/**
    	 * woocommerce_before_subcategory hook.
    	 *
    	 * @hooked woocommerce_template_loop_category_link_open - 10
    	 */
    	do_action( 'woocommerce_before_subcategory', $category );
    
    	/**
    	 * woocommerce_before_subcategory_title hook.
    	 *
    	 * @hooked woocommerce_subcategory_thumbnail - 10
    	 */
    	do_action( 'woocommerce_before_subcategory_title', $category );
    
    	/**
    	 * woocommerce_shop_loop_subcategory_title hook.
    	 *
    	 * @hooked woocommerce_template_loop_category_title - 10
    	 */
    	do_action( 'woocommerce_shop_loop_subcategory_title', $category );
    
    	/**
    	 * woocommerce_after_subcategory_title hook.
    	 */
    	do_action( 'woocommerce_after_subcategory_title', $category );
    
    	/**
    	 * woocommerce_after_subcategory hook.
    	 *
    	 * @hooked woocommerce_template_loop_category_link_close - 10
    	 */
    	do_action( 'woocommerce_after_subcategory', $category ); ?>
    </li>
    <?php endif ?>

    Hope this can be helpful to someone else.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide both Categories and Products on Shop Page only’ is closed to new replies.