Filter posts by custom fields


To filter posts by custom field(s), do the following:

Step 1: Adding a custom field

  1. Edit a map
  2. Open the widget “List & filter Settings”
  3. Click on the menu “Search filter settings”
  4. Scroll to the section “Custom fields parameters”
  5. Open the group field “Custom field 1” (or click on the button “Add new custom field” if this is not the first time to add one)

Step 2: Setting up the custom field parameters

  1. In the field “Label/Title”, enter the title of your custom field (the title that’ll appear in the filter form! e.g. “Price”)
  2. In the field “Custom field name”, enter the name (meta key) of your custom field.
  3. In the field “Description”, enter a description of your custom field. The description will appear in the filter form!
  4. Choose the display type of your custom field by selecting an option in the field “Display type”.
  5. Open the group field “Field parameters” and adjust the settings of your custom field:
    1. If you’d like to add a symbol/text (a curreny for example) next to the custom field, type it in the field “Symbol”, then, choose its position by selecting an option in the field “Symbol position”.
    2. To show the number of posts assigned to your custom field, select the option “Yes” in the field “Show count”. This option will help users to know if they may get any result before filtering the posts!
    3. If the display type of your custom field is “Range text input (Min & Max)”, you may need to make some adjustments in the fields “Text Mask”“Clear if not match the mask?” and “Text placeholder”. Under each of this fields, you’ll find a description of what you need to do!
    4. If the display type of your custom field is “Price input” or “Range Price input (Min & Max)”, you may need to make some adjustments in the fields “Cents separator”“Thousands separator”, “Price limit”, “Cents limit” and “Allow negative price?”. Under each of this fields, you’ll find a description of what you need to do!
    5. If the display type of your custom field is “Checkbox” or “Radio” or “Select”, you may need to make some adjustments in the fields “”Search All” Option and “”Search All” Label”. Under each of this fields, you’ll find a description of what you need to do!
    6. If the display type of your custom field is “Datepicker, you may need to make some adjustments in the fields “Custom field date format”“Date components separator”, “Start date”, “End date” and “Week start”. Under each of this fields, you’ll find a description of what you need to do!
  6. Open the group field “Query parameters”:
    1. In the field “Are custom field values serialized?”, select “Yes” if your custom field values are stored in the database as a serialized ARRAY. Alternatively, choose “No” if the custom field values in the database are simple strings. Please note that with serialized custom fields, the compare parameter of the meta query will always be set to “LIKE”!
    2. In the field “”Compare” parameter”, choose the operator to test with when filtering the posts.
    3. In the fields “Orderby parameter” and “Order parameter”, choose the display order of the custom field values. For example, if you use a custom field to save the post’s price and that you want to display all available prices in the filter form as a checkbox list, the plugin will automatically get all the values saved inside the database and will display them according to that “orderby” and “order” parameters.
  7. In the field “Display status”, choose whether to open or close the custom field container on page load.
  8. In the field “Visibility”, choose whether to show or hide the custom field in the filter form. This option is useful in case you want to temporarily hide the custom field without having to delete it!
  9. To add a new custom field, click on the button “Add new custom field” and repeat the above steps.

Step 3: Defining the relationship between all your custom fields

Under the button “Add new custom field”, in the field “”Relation” parameter”, select the parameter that defines the relationship between all your custom fields. For example, let’s say you have two custom fields (“Price” and “Size”). Let’s also imagine a situation where a user wants to filter the posts by a price that equals “500$” and a size that matches “XL”:

    • By selecting the relation parameter “AND”, the plugin will try to get all posts having the price “500$” and the size “XL”. Note that a post must have these two values in order to be displayed!
    • By selecting the relation parameter “OR”, the plugin will try to get all posts having the price “500$” or having the size “XL”. Note that a post must have only one of these two values in order to be displayed!

In the same context