• Resolved sebastienfry

    (@sebastienfry)


    Hi,

    I try to remove woocommerce loop on some category product page of a website using woocommerce.

    I’m looking to a snippet to introduce in functions.php.

    Any help appreciated.

    Than you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @sebastienfry

    Can you share more details with us of what exactly are you trying to achieve? Maybe a screenshot can help us to understand and visualize it better!

    I’d recommend using this tool to take screenshots:

    https://snipboard.io/

    I hope to hear from you soon! All the best!

    Thread Starter sebastienfry

    (@sebastienfry)

    I’d like to remove the loop on some category product page.
    My goal is to customize category product page with gutenberg block.
    I already know how to add description before and/or after products loop.
    Now I’d also like to remove all the products on the category product page (but only in one or two category, not all category product page).

    For exemple, this snippet is to remove all the products from shop page.
    I need the same for category product page :

    add_action( 'pre_get_posts', 'stuff_remove_products_from_shop_page' );
    function stuff_remove_products_from_shop_page( $q ) {
       if ( ! $q->is_main_query() ) return;
       if ( ! $q->is_post_type_archive() ) return;
       if ( ! is_admin() && is_shop() ) {
          $q->set( 'post__in', array(0) );
       }
       remove_action( 'pre_get_posts', 'stuff_remove_products_from_shop_page' );

    Hi @sebastienfry

    If I understood you correctly, you want to hide some specific products from a category page, is that correct?

    This is a bit out of scope for us, but I found this article that comes in handy when trying to hide some specific products on a category page:

    https://www.businessbloomer.com/woocommerce-remove-specific-category-shop-loop/

    If you’re comfortable with coding, you can add more slugs at your terms [array].

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    All the best!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘remove loop on some category product page’ is closed to new replies.