1. AAWP
  2. Documentation
  3. Functions
  4. How-to sort products

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):

[amazon bestseller="smartphone" orderby="title" order="asc"]

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):

[amazon bestseller="smartphone" orderby="price" order="desc"]

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):

[amazon bestseller="smartphone" orderby="percentage_saved" order="desc"]

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:

[amazon bestseller="smartphone" orderby="price" order="desc" order_items="20" items="10"]

This way, the plugin fetches 20 products (instead of only 10) from the API and orders them by their price. Anyway your list only shows a total amount of 10 products, but includes products which might not be included without making use of order_items.

When passing a browse node id (bestseller and new releases only), the API only returns a maximum amount of 10 products. This also applies to order_items. In case you want to display or order more than 10 products, you have to forward a keyword instead of the browse node id.
When increasing the range of products, the plugin needs to fetch, store and update more data than usual. We recommend only using the extra attribute, if you’re totally unhappy with the former results.

Was this article helpful?

Related Articles