[Plugin: WooCommerce] Show empty product categories (8 posts)

  1. wilsonxyz
    Posted 3 years ago #

    Please help me guys, I'm new to wordpress and have been finding and trying to figure this out for days but got stuck...

    I am using wooCommerce and have a long list of categories with subcategories. However they are not shown on the site unless the category has a product in it. I want to make it so that all categories are displayed, including both the category page (www.mysite.com/?product_cat=mycategory1) and the widget column.

    I tried to mess with something called shortcode, but can't enter shortcodes in editing the category. Tried to edit style.css but don't know what to put or if that's the right place to go.

    Please help!!! Thank you x 10000000000!!

    [No bumping. If it's that urgent, consider hiring someone.]

  2. nikoza
    Posted 3 years ago #

    If you are quering the products in order to display them remember to add this parameter: "hide_empty" => false

    $terms = get_terms('product_cat', array('hide_empty'=>false));

    Good luck!

  3. wilsonxyz
    Posted 3 years ago #

    Thank you for your help! Much appreciated!! Can you also teach me where to put/modify this code? I don't know where I can find it.

  4. sk
    Posted 3 years ago #

    I couldn't work out how to do this using woocommerce_product_subcategories with something like
    <?php woocommerce_product_subcategories( array( 'hide_empty' => 0) ); ?>

    So instead it works fine to move that whole function to your themes functions.php file set hide_empty to 0 like this https://gist.github.com/3926139

    Not really an ideal solution I think. Anyone else have ideas? I tried some of these resources to help:

  5. ctpweb
    Posted 3 years ago #

    Thanks renegadesk! Your code works great!

    Is there a solution for the product categories widget to show empty categories? Cheers!

  6. sk
    Posted 3 years ago #

    Great that the code helped ctpweb! Not sure about the widget though, but there is a widget called Collapsing Categories that you could use instead

  7. chinora
    Posted 3 years ago #

    Don't know if you're still looking for a solution, but this works for me (on woocommerce 1.6.6 at least)

    add this to your functions.php

    add_filter('woocommerce_product_categories_widget_args', 'woocommerce_show_empty_categories');
    function woocommerce_show_empty_categories($cat_args){
    	return $cat_args;
  8. jakub s
    Posted 3 years ago #

    chinora thank's! it works on WooCommerce 2.0.12

Topic Closed

This topic has been closed to new replies.

About this Topic