• So all over the net there’s answers as to how to get only categories and not products to show up on your parent categories (not main shop page).

    So long story short, I’ve found that somehow it’s my (simple) theme that’s causing only products to show up and not sub categories. Yes I tested in 2022 and in that theme it does display the sub categories as intended.

    I’ve stripped my theme down to the barest essentials and it still will only display categories vs showing me the sub categories.

    Does anyone know what in a theme would hinder sub categories from showing?

    The shop in question is setup this way:

    Shop Page / Category / Sub Category / Products

    Any ideas are highly appreciated.

    • This topic was modified 2 years, 6 months ago by Dave Lauretti.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Kaushik S. a11n

    (@kaushiksomaiya)

    Hi there!

    Thanks for contacting us.

    I understand your theme is not showing sub-categories on the main product category listing page.

    This may be due to the way archive templates are coded in the theme.

    You may want to observe the WordPress template hierarchy here and see if your theme is having a template present for product category archive. The template might be coded to show only products.

    At last, it would be best to get in touch with the theme developer for advice on this.

    I hope this was helpful. ??

    Thread Starter Dave Lauretti

    (@345ad)

    Hi Kaushik. Yes I’m the developer. I found the child categories are using page.php. Should it be using another file in order to make this work – as you say, an archive.php page?

    I found even the main Shop page is using page.php of which I only have this code in – when I stripped out everything but the following, it still only displays the products:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php the_content('<p>Read the rest of this page &raquo;</p>'); ?>
    
    <?php endwhile; endif; ?>

    Hello,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    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.

    Thread Starter Dave Lauretti

    (@345ad)

    Hi MayKato – do you know if another file besides page.php can be used to display the categories? Does archive.php do the same?

    Hi @345ad!

    I am not sure if I understood what exactly are you looking for, but you can use an action hook woocommerce_after_subcategory, which is located in your content-product-cat.php (WooCommerce/templates/).

    I am sure that you’ve already double-checked it, but just to be on the safe side, have you checked the WooCommerce settings on your customizer (WordPress DashBoard > Appearance > Customize > WooCommerce)?

    On your Category display for example, you can set it to show subcategories and products (or only subcategories):

    Image link: https://snipboard.io/co7VaP.jpg

    Let me know if this is not exactly what you’re looking for and I’ll be happy to take a closer look at it again!

    All the best,

    Thread Starter Dave Lauretti

    (@345ad)

    Hi André. Thank you for your reply.

    Yes I’ve done and checked every area including the Woocommerce settings etc.

    It appears that my theme is causing only products to show in sub categories vs showing the sub categories.

    And for testing purposes, in my theme I’ve stripped everything down, removed all CSS, removed all JS and only kept in the loop and still the products only show, not the child categories.

    Are you saying I can grab the action hook woocommerce_after_subcategory from the Woo product cat file and add it to functions.php?

    Plugin Support Paulo P – a11n

    (@paulostp)

    Hello,

    Personally, I’m not knowledgeable enough about theme development to help you out here. If André has an additional insight, maybe he’ll share it here later.

    I would suggest that you examine Storefront‘s code. This is WooCommerce’s own theme, and it is great for theme developers.

    Other than that, the Facebook and Slack groups that MayKato shared above are probably your best option, as a lot of the developer community is there.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘What Would Stop My Theme From Displaying Only Woo Categories and Not Products’ is closed to new replies.