Title: Order products by multiple fields
Last modified: October 5, 2020

---

# Order products by multiple fields

 *  Resolved [Denis](https://wordpress.org/support/users/butifarra/)
 * (@butifarra)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/)
 * Hello. I want to order products by multiple fields (attributes, or arguments,
   as you prefer to call them).
    I want to order a machinery catalog by brand and
   between each brand by year, and between year by price. That is, for example: 
   John Deere machines go first. Among all the John Deere, the order must be by 
   year descending, and when the year coincides, the more expensive go first. How
   can I achieve this? I read a lot of material but nothing helpful. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Siew](https://wordpress.org/support/users/kosiew/)
 * (@kosiew)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13496274)
 * Hi there,
 * For this purpose, you can check out this article at WebHat: [https://www.webhat.in/article/woocommerce-tutorial/custom-order-by-attributes/](https://www.webhat.in/article/woocommerce-tutorial/custom-order-by-attributes/)
 * Please try the above and let us know how it goes.
 *  Thread Starter [Denis](https://wordpress.org/support/users/butifarra/)
 * (@butifarra)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13500473)
 * Hi again, I did what the page says, but it allows you to sort by one field OR
   another. I want to sort by one field AND another field inside that same group.
   It can be done easily in SQL adding two arguments when sorting, but I don´t know
   how to do it here.
    Machines have several brands, and every machine has a year
   and a value. Let’s see this simple case. I have 7 machines. 3 John Deere, 2 Case
   and 2 New Holland. Every machine has a different year model and value. John Deere
   1590 year 2009 $ 15000 John Deere 1580 year 2015 $ 10000 John Deere 1780 year
   2015 $ 20000 Case 3030 year 2010 $ 20000 Case 5050 year 2010 $ 10000 New Holland
   1515 year 2018 $ 50000 New Holland 1520 year 2020 $ 40000 I want the John Deere
   machines to appear first, after, the Case, and after, the New Holland. And, inside
   each subset, the order is year, and when the year coincides, by price. That is
   the order I want. John Deere 1780 year 2015 $ 20000 John Deere 1580 year 2015
   $ 10000 John Deere 1590 year 2009 $ 15000 Case 3030 year 2010 $ 20000 Case 5050
   year 2010 $ 10000 New Holland 1520 year 2020 $ 40000 New Holland 1515 year 2018
   $ 50000
 *  Thread Starter [Denis](https://wordpress.org/support/users/butifarra/)
 * (@butifarra)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13515460)
 * Hi, do you have any suggestion? I can´t solve this. Thanks in advance.
 *  [Siew](https://wordpress.org/support/users/kosiew/)
 * (@kosiew)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13520693)
 * Hi there,
 * You can check out [https://stackoverflow.com/questions/44690734/multiple-order-by-in-woocommerce](https://stackoverflow.com/questions/44690734/multiple-order-by-in-woocommerce)
   on how to include multiple order-by attributes.
 * I hope this points you in the right direction.
 *  Thread Starter [Denis](https://wordpress.org/support/users/butifarra/)
 * (@butifarra)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13528479)
 * Hi again. I had found this post, but I don´t know if it is what I need, and if
   it is, I don´t realize how to make it work or if all the code I need for the 
   functions.php file is there.
 *  [Siew](https://wordpress.org/support/users/kosiew/)
 * (@kosiew)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13570477)
 * Hi there,
 * If you’re looking for custom code help, you might be able to find someone willing
   to volunteer their time and knowledge in the free PHP support forum at [PHP Builder](
   [http://board.phpbuilder.com/forumdisplay.php?2-General-Help](http://board.phpbuilder.com/forumdisplay.php?2-General-Help))
   or within the [Advanced WooCommerce]([https://www.facebook.com/groups/advanced.woocommerce/](https://www.facebook.com/groups/advanced.woocommerce/))
   group on Facebook.
 * I’m going to mark this as resolved – if you have any further questions, you can
   start a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Order products by multiple fields’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Siew](https://wordpress.org/support/users/kosiew/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/order-products-by-multiple-fields/#post-13570477)
 * Status: resolved