Omit specific product categories from WooCommerce shortcode

admin2025-06-07  30

I assumed this would be simple, but I'm having a hard time sorting it out. All I want to do is use the standard [product_categories] shortcode from WooCommerce to show all of my product categories except for a few. Basically I have two types of categories: location based (basically sales lot inventory) and style based (different types of products), so I want to show a list of the style categories (which could change or have additional styles added at some point) and leave out the locations, which are unlikely to change anytime soon.

So therein lies the problem. I know I can use the shortcode to only display certain categories by slug or ID, but I'm hoping to avoid having to modify the short code every time we need to add a new style. If I could do something like [product_categories category!="inventory1, inventory2, inventory3"] that should fix my issue!

Is this possible?

I assumed this would be simple, but I'm having a hard time sorting it out. All I want to do is use the standard [product_categories] shortcode from WooCommerce to show all of my product categories except for a few. Basically I have two types of categories: location based (basically sales lot inventory) and style based (different types of products), so I want to show a list of the style categories (which could change or have additional styles added at some point) and leave out the locations, which are unlikely to change anytime soon.

So therein lies the problem. I know I can use the shortcode to only display certain categories by slug or ID, but I'm hoping to avoid having to modify the short code every time we need to add a new style. If I could do something like [product_categories category!="inventory1, inventory2, inventory3"] that should fix my issue!

Is this possible?

Share Improve this question asked Oct 10, 2018 at 13:36 iprobablyhavenoanswersiprobablyhavenoanswers 431 silver badge8 bronze badges 2
  • It's definitely possible. It isn't out-of -the-box functionality, which is why the devs probably answered it's not currently possible, but you can modify how the existing shortcode works, or even write your own. – Pim Commented Oct 15, 2018 at 14:52
  • You're right, I shouldn't have said it isn't possible, just not currently built-in to the stock plugin. That said, I'm personally not skilled enough nor concerned enough at this point to put that kind of tweak together, so I'm content to let it ride. I will, however, edit my answer to reflect your point! – iprobablyhavenoanswers Commented Oct 16, 2018 at 15:10
Add a comment  | 

1 Answer 1

Reset to default 1

I submitted this question to the WooCommerce devs as well and they've officially confirmed it's not currently possible without modifying the shortcode. I will be submitting a feature request, though, so should anybody else find themselves in need of this, please track down that feature request and give it some props or submit it again on your own. I don't think the functionality should be difficult for them to include, so I would image it will have a decent likelihood of being adopted for a future release (if it gets enough steam, of course).

I'm not sure exactly what kind of platform they're using for their feature requests, but I may come back and link it here if it's like a popularity- or vote-based system.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749258010a317674.html

最新回复(0)