Just started playing around with Woocommerce, ran into a problem. I have a bunch of items (100+) and all of them only have a number as product title, 1,2,3 etc. The problem is that Woocommerce outputs the products like this: 1,11,12,13,14,15,16,17,18,19,2,20 – and so forth. How can I make it output correctly?

closed as off-topic by kaiser May 21 '14 at 11:25

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.

  • Seems completely valid to me. Yes, he's saying Woocommerce but it's a WP_Query question at the heart of it all. – Nathan Jul 8 '16 at 15:25

You'll either have to sort/order your products manually or create a custom sort order within WooCommerce. For that take a look at the WooCommerce docs and this snippet for doing just that.

In this case you're also going to have to do a bit of MySQL manipulation as well so that you're sorting the numbers numerically. See this post on stackoverflow for an example.

NOTE: You may have some performance issues with the MySQl as a result.

  • Thanks for your reply! I tried this: wordpress.org/support/topic/… but I didn't seem to work (The order didn't change when switching between asc/desc). What could be wrong? – INT Nov 26 '12 at 20:46
  • Without seeing your exact code and perhaps a URL I could only guess. But my answer is two part, you still have to account for the MySQL portion to sort as you want to. – Steve Nov 26 '12 at 20:51
  • I realize it's impossible for you to know what's wrong for my particular install. I will try and work with the MySQL solution instead. Could you please elaborate a little on how I can filter the results via MySQL for Woocommerce? I'm not sure where I should put any code or tie in with Woocommerce for this matter. – INT Nov 26 '12 at 21:05
  • Is your site publicly accessible? Can you share the URL so I can take a look at it? – Steve Nov 26 '12 at 21:18
  • 1
    Answers should be more than plain links. They should actually be an answer instead of a route where someone will maybe find an answer. Please help preventing link rot, edit your answer and provide the needed information that helps the OP as well as later visitors to solve their problem. – kaiser May 21 '14 at 11:25

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