I want to figure out how to change our CRAFT CMS-built website's search functionality to deliver search results in descending chronological order. Currently, the oldest entries are at the top and people often don't scroll to the bottom. This has caused confusion for our organization. Any help would be greatly appreciated.

Running Craft CMS 3.7.38

New contributor
Erin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Are you talking about a search implemented via code for your website or do you mean the Control Panel search?
    – Henrik
    Jun 21 at 19:52
  • I mean the search implemented code for the website
    – Erin
    Jun 21 at 19:54
  • Can you provide some code how it is implemented? if you have this syntax {% set results = craft.entries().search(searchQuery).orderBy().all() %} ,you can change it then to this: .orderBy('postDate DESC').
    – Henrik
    Jun 21 at 20:06
  • Unfortunately, I didn't build the code, but am on the CMS side since I just joined the company. Trying to get access to the backend, but is there any shortcut on the CMS side to seeing the implementation? I know this is scope creep, but maybe i can then answer the question
    – Erin
    Jun 21 at 20:10
  • to change the order you eventually need full access to the code, so i would guess the safest approach is to get access to the templates. can you get to the template via ftp?
    – Henrik
    Jun 21 at 20:14


Your Answer

Erin is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.