I have created a search results page to display matching entries to a search term, ordered by the most recent.
The set-up works well for all entries which are not part of a structure. Results of entries within a structure appear at the end of the search results together and in reverse date order. Could this be that structure sections are searched separately from the rest of the site? The results are displaying, just not how they should.
I am working with legacy code and my knowledge of this feature is very limited.
Is anyone able to point me in the right direction for including entries from structures within the rest of the search results, and in date order?
Thank you!
{% set searchQuery = craft.app.request.getParam('q') %}
{% set entries = craft.entries()
.search(searchQuery)
.all() %}