There might be a situation where you want to re-order a list of products by title, price etc. This can be done by using the shortcode attributes “order” and “orderby”.
Sorting examples and options
Sorting products by title
In this example we assume you want to sort a list of products by title (from A to Z):
In case you want to sort the products in reverse order, change the order attribute to desc
.
Sorting products by price
In this example we assume you want to sort a list of products by price (from highest to lowest):
In case you want to sort the products in reverse order, change the order attribute to asc
.
Sorting products by price reduction
In this example we assume you want to sort a list of products by their price reduction (from highest to lowest):
In case you want to sort the products in reverse order, change the order attribute to asc
.
What shortcodes can be used for sorting?
Sorting can be applied when displaying multiple boxes, bestseller lists and new releases lists.
Overview of all available sorting options
“orderby” options
Value | Description |
---|---|
title |
Title of the product |
price |
Advertised price of the product |
percentage_saved |
Price reduction (in percentage) of the product |
amount_saved |
Price reduction (total amount) of the product |
rating |
Rating (numeric) of the product Right now ratings cannot be guaranteed (see this article). That’s why it’s not recommended to order by rating. |
“order” options
Value | Description |
---|---|
asc |
Ascending order (e.g. low to high or A to Z) |
desc |
Descending order (e.g. high to low or Z to A) |
Advanced information
Increasing the range of products for sorting
It’s possible to sort an even larger number of products, but only display a lower amount of products. The benefit is, that the sorting can be applied to more products which might give you better results.
Therefore add the shortcode attributes items
and order_items
as follows:
This way, the plugin fetches 10 products (instead of only 5) from the API and orders them by their price. Anyway, your list only shows a total amount of 5 products, but includes products that might not be included without making use of order_items
.