• Resolved lasseruud

    (@lasseruud)


    Wordpress: 5.6.2
    WooCommerce: 5.0.0

    I have a site with a lot of categories and subcategories. Up to 3 levels of subcategories. Its working well, but I want to have some pages that displays only content from certain subcategories.

    Using the block-editor, I’m able to add a block and show only products from specified categories, however, I want to add empty categories to this selection as well. They might be empty now, but I will add products later. When I search for categories in the right hand panel, only categories with products are displayed.

    More specific, my categories are:
    Type of clothing A
    – Sizes from xx to xx
    — Size xx
    Type of clothing B
    – Sizes from xx to xx
    — Size xx

    I want to add a page that only displays items from all “Size xx” subcategories.

    Is there any way to make all (sub)categories avalable for selection in the block editor, including empty ones?

    I’ve tried to add this snipped without help:
    add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @lasseruud ,

    If I understand correctly, you want to select the empty categories in the product blocks. Is that right?

    It looks like the filter you have used does not have any impact on the blocks. I could locate a similar solution for blocks as well.

    If the goal is to show products from categories, regardless of the fact that they are empty or not, you can use the [products] shortcode.

    You can target a specific category in the shortcode like this –
    [products category="music"]

    You can find more examples and parameter lists here.

    I hope this helps.

    Thank you 🙂

    Thread Starter lasseruud

    (@lasseruud)

    That worked well. However, as I got over 200 categories, it took some work, but I solved my initial problem. Thank you. 🙂

    Beginning to think I should organize my categories in another, more efficient, way.

    I’ve got 12 main categories of clothing, with each category holding 19 sizes.

    I want to have a meny displaying both by type of clothing and by size. For now, I have a category for each size in every main category. I might be able to solve this by having 12 main categories and 19 size categories, displaying them using:

    [products category="pants, size-86" cat_operator="AND"]

    ?

    Bo doing this, I would have to manually create a page for every combination like I just did with the sizes?

    Hello @lasseruud ,

    If the plan is to categorize the products based on their sizes then I assume this is the way to go. However, most of the time the size of a product is added as an attribute.

    This gives you the flexibility to filter the products based on this attribute. You will not need to create separate pages for each size. You will only create one category “clothing” and then using the product filter widget customers can filter through the desired item on the category archive page. This filter has one disadvantage. You are unable to use this with the [products] shortcode.

    You might want to use a plugin like this to have both shortcode and filter support – WOOF – Products Filter for WooCommerce.

    Thank you 🙂

    Thread Starter lasseruud

    (@lasseruud)

    This is a used clothes store, so I’ve only got 1 item of each. I don’t know if attributes is the way to go with only 1 item and not several sizes of each piece of clothing.

    I’m marking this thread as solved. My initial question was answered. My further questions regards other issues. 🙂

    Thank you @rur165 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show all (sub)categories in block editor’ is closed to new replies.