Changing or Adding New Sorting Options
This is one of the most powerful and underused features of GeoDirectory! With the Sorting options builder, you can create custom sort options based on your custom fields.
What are Sorting Options?
Sort options let you order listing results in a specific way. By default, listings are sorted by "Newest" meaning that newly added listings will be shown first.
Sort options can be used in many places including on archive pages and in GD > Listings widgets.
Some of the sort option features are;
- Most default fields can be used as a sort option.
- Most custom fields can be used as a sort option.
- Add as many different sort options as are needed.
- Enable a field to be a sort option by selecting "Include this field in sorting options" under the edit field > show advanced options.
- A single sort option can have many sorting factors.
- Any Sort option can be set as the default for that CPT.
- All sort options can also be used in the GD > Listings widget.
If a field can be used to create a sorting option, you will see this in the Custom Field settings.
Check this option to include the field in the sorting option
Adding or Editing a Sort Option
Each Custom Post Type (CPT) has its own separate sort options. Sort option settings are under the CPTs settings, Places > Settings > Sorting.
Let's create an example using our real-estate dummy data and add a new sort option that orders listings by the size of the property.
- The Area custom field should already be showing as an available sort type, click that to add it to the sort options.
You will then be presented with the settings for the sort option;
- Frontend title - This is the text used for the sort option.
- Ascending or Descending - Select the sort direction: (A-Z or Z-A)
- Default sort - This sets the option as the overall default sort value, there can be only one.
- Is active - Set if this sort option is active or not, if not it will not be shown to users.
We set the title as Largest Area (Sq Ft) and the sort direction to Descending (largest to smallest) and set it active.
Drag the sort option up or down to set the position in the list.
The results on the frontend after selecting the new option will order listings by the largest area first
Sort listing by whether they are featured or not, showing the featured listings first. This is a great way to promote listings that receive special consideration.
How to Nest Different Sort Options?
GeoDirectory allows nesting of sorting options. For instance, you can add "Featured" as a field, and then change the Title to "A-Z" then add the Title field as a sub-item or nested item. Doing so will sort first by featured, and then by title.
To accomplish this, you'd follow the same model as for adding other sorting options, but instead, simply add the nested field as a sub-item.
In the above image, GD will first sort the listings by Newest, and if two listings have the same date, it will sort them alphabetically. Perchance the titles are also the same, it will sort by ratings.
Note that nested sort options are not shown on the frontend. These are just hidden sort options that allow you to adjust or tweak the sorting options.