Filtering product tables by keyword or search term
Search box above the table
By default, product tables are displayed with a search box above the table (top-right). This allows your users to instantly filter the table to products with a specific keyword or search term.
In this example, the user has typed the term “t-shirt” in the search box, which has filtered the table to the 4 products which match that term:
If you are not using lazy load then the search box will search all data in the table, so users can search by price, stock, etc. The search box is more restricted if your table uses lazy load.
To change the position of the search box (or hide it altogether), please see the display options article.
Search term option
You can also choose to filter the products in the table when it is first displayed. To do this, add the
search_term option to your shortcode. E.g.
There are a couple of notes and caveats with this option:
- When using lazy load, the
search_termoption will only search the product name and description – the other columns will not be searched.
- The search is case insensitive.
- As with the main WordPress search, the search is done by keyword, not individual words. So if you use
search_term="product1", then it will match products with the name “product1”, “product12”, “Product12 – Large”, etc.