Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

good morning, I need to display the shop base page in a category layout,meaning first show all the products from category A and beneath it all the products from category B and so on.. I trying to use the built-in woocommerce shortcode -"products by category slug" but instead it displays products by products slug,what is the solution?

here is the shortcode

[product_category category="" per_page="12" columns="4" orderby="date" order="desc"]

thank you

share|improve this question

closed as off-topic by toscho Apr 18 at 19:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Please edit your question to include the relevant shortcode callback code. –  Chip Bennett Mar 2 at 12:42

1 Answer 1

up vote 0 down vote accepted

What @ChipBennett meant is to show the actual code that is represented by the shortcode, it can be found in the source. Take a look at this to see what's behind it - it is a WP_Query.

Aside from that, the problem is - as far as I can tell - that you're misinterpreting what the shortcode does. Especially regarding the orderby parameter of WP_Query, which is not designed to order by category/taxonomy. It is just not part of core and

this is not something we want in Core. Here's a thorough explanation from Otto:1

Here on WPSE to be exact, as answer to Using wp_query is it possible to orderby taxonomy?.

share|improve this answer
    
hi thank you :) I am trying to understand - in my virtual shop i will have only 3 categories shirts shoes and dresses like in a real shop each category should have their own shelf/department,so lets say i want that category shirts(and its products of course) will always show before category shoes ,where do i put the code for that? and should i use custom fiels type to achive this? –  take that Mar 3 at 2:05
    
I guess the easiest way to do this to use multiple loops, which, in your case, equals using the shortcode multiple times. Of course you've to adapt it to your needs. @takethat [product_category category="shirts"] \\display first category [product_category category="shoes"] \\display second category [product_category category="dresses"] \\display third category –  ialocin Mar 4 at 12:41
    
I understand now - so you have to do it manually for each specific shop (needs),by the way i found a plugin wordpress.org/plugins/post-types-order that helps a little.thank you again. –  take that Mar 4 at 13:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.