Skip Navigation

[Resolved] Sort search results by custom field

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 4 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2205387
Screen Shot 2021-10-25 at 4.36.22 PM.png

Tell us what you are trying to do? I would like to sort text search results by the custom field "year-of-recording" and then by post-title. The Toolset View states that "Since you are using a text search with Relevanssi, the order of results may be according to relevance and not according to this selection. If the visitor searches by text, the results will be ordered by relevance." Is there a way for Toolset to take the Relevanssi results and then sort those by custom field "year-of-recording" followed by by post-title?

Is there any documentation that you are following? The Relevanssi site has some info that may help with this but I do not understand how to add the code within a Toolset view: hidden link

Is there a similar example that we can see?

What is the link to your site? hidden link

#2205823

Hello,

For the question:
Is there a way for Toolset to take the Relevanssi results and then sort those by custom field "year-of-recording" followed by by post-title?

Please check our document:
https://toolset.com/course-lesson/searching-texts-in-custom-fields-with-toolset-and-relevanssi/#integration-with-custom-searches
section "Integration with custom searches":

Once you add a search filter that includes custom fields, the entire search operation is performed by the Relevanssi plugin, which means that Relevanssi is also responsible for providing the results order. This is why the Views sorting order options are not used.

So the problem is in Relevanssi plugin side, you can follow their document to setup your custom codes:
hidden link

If you need more assistance for it, please provide a test site with same problem, also point the problem page URL and view URL, where I can edit your custom PHP codes, thanks