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
Only show products without a certain keyword in their title
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.
Only show products with a price higher than 100 EUR/USD etc.
Only show products with a price between 100 and 200 EUR/USD etc.
Only show products with an exact price of 100 EUR/USD etc.
Only show products which are currently on sale
Only show products which are available
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:
This way, the plugin fetches 10 products (instead of only 5) from the API and filters them by their title. Anyway, your list only shows a total amount of 5 products, but includes products that might not be included without making use of filter_items
.