Every now and then, you come across an issue SO apparently simple you think you have to be stupid not see the answer and then it turns out – there isn't an answer. This is my query.
Is there a way to have Related Products in WooCommerce only display products from a specific subcategory?
Here's the issue.
I have a parent category, “MAKE UP” with 8 subcategories. As far as I can tell, the default Related Products will generate products randomly from both parent and child categories. This is crazy.
The parent category is only broadly related to its children, so showing “related” products from the parent category for products in the child category is unhelpful... to the point of being downright confusing.
I found a plugin called, WooCommerce Custom Related Products Pro. (Note the 'Pro'. Yes, I paid for it.) It works, BUT there's no global settings which means you have to manually add subcategories by product.
I only have 78 products in my shop so far but at around 1 min per product, that's 1 hour & 18 minutes of work!
I used the excellent WP All Import plugin to do the heavy lifting of product amendments, but the WooCommerce Custom Related Products Pro fields don't appear in the import.
It seems SO basic that I have to believe that I'm being stupid! Is there any way to set global parameters for Related Products?
Love to know!
Martin
functions.php
file or via a plugin like the Code Snippets plugin. Avoid adding custom code directly to the functions.php
file in your parent theme, as it will be overwritten whenever you update the theme.
Finally, if you're not comfortable editing the underlying code that powers your site, you can always hire a WooCommerce developer to tackle this minor change for you in less than an hour. You can start a conversation with an expert right here: https://wp101.com/help/
I hope this helps!