Reputation: 141
I'm building a site search page using WPSOLR and need to have a form that allows users to choose to sort search results by either ascending or descending alphabetical order. I am looking into writing a filter to serve this purpose but could use some general guidance on the topic. Has anyone done something like this before with Wordpress? Thanks in advance.
Upvotes: 0
Views: 243
Reputation: 50
If your field name is 'field1', just use the parameter: &wpsolr_sort=field1_str_asc or &wpsolr_sort=field1_str_desc
Some fields are predefined and come with the plugin. You can see them when you setup the sorts in the wpsolr admin.
You also have predefined filters to modify the Solarium query as you wish (without using parameters if you want to do it silently). This filter contains an example to add 3 sorts: https://www.wpsolr.com/guide-category/actions-and-filters/#2787
Upvotes: 1