To filter posts by custom field(s), do the following:
Step 1: Adding a custom field
- Edit a map
- Open the widget “List & filter Settings”
- Click on the menu “Search filter settings”
- Scroll to the section “Custom fields parameters”
- 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
- In the field “Label/Title”, enter the title of your custom field (the title that’ll appear in the filter form! e.g. “Price”)
- In the field “Custom field name”, enter the name (meta key) of your custom field.
- In the field “Description”, enter a description of your custom field. The description will appear in the filter form!
- Choose the display type of your custom field by selecting an option in the field “Display type”.
- Open the group field “Field parameters” and adjust the settings of your custom field:
- 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”.
- 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!
- 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!
- 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!
- 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!
- 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!
- Open the group field “Query parameters”:
- 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”!
- In the field “”Compare” parameter”, choose the operator to test with when filtering the posts.
- 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.
- In the field “Display status”, choose whether to open or close the custom field container on page load.
- 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!
- 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
- Activate the search filter
- Display the search filter in left side or the right side of the list
- Show or hide the search filter on page load
- Display the buttons “Filter” & “Rest” on top and/or the bottom of the search filter form
- Change the display order of the fields in the search filter form
- Filter posts based on a keyword
- Filter posts by publish date
- Filter posts by taxonomies
- Change the text displayed in the button “Filter”