Skip to main content

How to create Checkbox filter by text metafield

Updated over a year ago

Checkbox, select, and radio filters are compatible only with matching metafield types (checkbox, radio, or select).

To use a text metafield for filtering, you’ll need to create an SQL query

Here’s an example:

SELECT DISTINCT meta_value
FROM {prefix}postmeta
WHERE meta_key = "adress_of_hotels"
ORDER BY meta_value ASC;

And this is filter set up:

In this case, the filter value and label must exactly match the example format. Just replace the field name "address_of_hotels" with your own metafield name.

If your metafield is Numeric type change this part of SQL query

ORDER BY meta_value DESC with this one ORDER BY CAST( meta_value AS DECIMAL ) DESC

Did this answer your question?