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

There might be a situation where you want to filter a list of products by title, price etc. This can be done by using the shortcode attributes “filter” and “filterby”.

Filtering examples and options

Filtering products by title

In this example we assume you want to filter a list of products by title:

Only show products with a certain keyword in their title

[amazon bestseller="smartphone" filterby="title" filter="iphone"]

Only show products without a certain keyword in their title

[amazon bestseller="smartphone" filterby="title" filter="iphone" filter_type="exclude"]

By default, filter_type is always set to include.

Filtering products by price

In this example we assume you want to filter a list of products by price:

Only show products with a price lower than 100 EUR/USD etc.

[amazon bestseller="smartphone" filterby="price" filter="100" filter_compare="less"]

Only show products with a price higher than 100 EUR/USD etc.

[amazon bestseller="smartphone" filterby="price" filter="100" filter_compare="more"]

Only show products with a price between 100 and 200 EUR/USD etc.

[amazon bestseller="smartphone" filterby="price" filter="100,200" filter_compare="range"]

Only show products with an exact price of 100 EUR/USD etc.

[amazon bestseller="smartphone" filterby="price" filter="100" filter_compare="equal"]

Only show products which are currently on sale

[amazon bestseller="smartphone" filterby="price" filter="offer"]

Only show products which are available

[amazon bestseller="smartphone" filterby="price" filter="available"]

By default, all filters mentioned above assume that you want to “include”
those products only. In case you want to “exclude” all products which meet the conditions above, please add filter_type and set it to exclude.

What shortcodes can be used for filtering?

Filtering can be applied when displaying multiple boxes, bestseller lists and new releases lists.


Overview of all available filtering options

“filterby” options

Value Description
title Title of the product
price Advertised price of the product

“filter” options

Value Description
Any text string Can be used in combination with filterby="title".
Any numeric number Can be used in combination with filterby="price". Only integers allowed, no decimal numbers.
offer Can be used in combination with filterby="price" in order to display/hide products which are on sale.
available Can be used in combination with filterby="price" in order to display/hide products which are available.

“filter_type” options

Value Description
include Only show products which meet the given conditions (standard behaviour).
exclude Only show products which do not meet the given conditions.

“filter_compare” options

Value Description
less Can be used in combination with filterby="price" in order to set a limit on top.
more Can be used in combination with filterby="price" in order to set a limit on bottom.
range Can be used in combination with filterby="price" in order to set price range.
equal Can be used in combination with filterby="price" in order to set an exact price.

Advanced information

Increasing the range of products for filtering

It’s possible to filter an even larger number of products, but only display a lower amount of products. The benefit is, that the filter can be applied to more products which might give you better results.

Therefore add the shortcode attributes items and filter_items as follows:

[amazon bestseller="smartphone" filterby="title" filter="iphone" filter_items="20" items="10"]

This way, the plugin fetches 20 products (instead of only 10) from the API and filters them by their title. Anyway your list only shows a total amount of 10 products, but includes products which might not be included without making use of filter_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 filter_items. In case you want to display or filter 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