Viewing 4 replies - 1 through 4 (of 4 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @mrloco,

    Based on what you have mentioned your Wall clock subcategory has products that currently are out of stock, so they must have been hidden from the page.

    Therefore, the subcategory is not empty since you still have products there although these products are out of stock. In this case, the “Hide empty categories” checkbox is working correctly.

    You’ll want to see if there are plugins that can hide categories or you can try the following snippet to hide a category from the shop page:

    
    //hide determinate category
    add_filter( 'get_terms', 'exclude_category', 10, 3 );
    function exclude_category( $terms, $taxonomies, $args ) {
      $new_terms = array();
      // if a product category and on a page
      if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_page() ) {
        foreach ( $terms as $key => $term ) {
    // Enter the name of the category you want to exclude in place of 'uncategorised'
          if ( ! in_array( $term->slug, array( 'wall-clock' ) ) ) {
            $new_terms[] = $term;
          }
        }
        $terms = $new_terms;
      }
      return $terms;
    }
    

    Add the code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin.

    We also have a full guide on how to add custom code here: https://woocommerce.com/posts/properly-add-woocommerce-custom-code/

    If the snippet won’t work for some reason, you can get further help from a web developer or customization expert via this link: https://woocommerce.com/customizations/.

    Hope this helps.

    Thread Starter mrloco

    (@mrloco)

    Hi, thanks for answering. Unfortunately, it does not work.

    con

    (@conschneider)

    Engineer

    Hi again,

    Maybe this can help: https://wordpress.org/plugins/hide-categories-or-products-on-shop-page/

    Please note that we provide no warranty or support for custom code or 3rd party plugins (meaning we cannot not help you further with this code snippet or WordPress.org / GitHub plugins). Use them at your own risk.

    **Also: Before you do that, please do make a full backup!**

    Kind regards,

    Plugin Support abwaita a11n

    (@abwaita)

    Hi,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, the above suggestions were helpful!

    If you have further questions, please feel free to open a new topic.

    Thanks.

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

The topic ‘Hide Empty Categories (widget and page)’ is closed to new replies.