0

I have a page that by default lists posts by chronological order. After the page is loaded, I want the user to be able to click on a button that will sort the posts by author alphabetically, then back to chronologically if desired. Is there a way to do this without sending a new query each time?

1 Answer 1

1

Yes and no,

As long as your blogs are all loaded at once (no pagination) this should be possible with javascript.

However if you are using pagination only the blogs shown on the page you are showing are loaded there for a new query is required each time. This can be done either by a full page reload, or asynchronous using a ajax call.

3
  • There is no pagination. So how would I accomplish this? My javascript knowledge is very limited. Thanks. Commented Jan 11, 2021 at 16:47
  • 1
    It would require some knowledge / understanding of javascirpt, and knowledge of customization of your template files. for the javascript you could implement something like suggested in this post link. for the data-attributes you have to customize the template to contain both category and author name to be able to sort by those fields.
    – Jasper B
    Commented Jan 12, 2021 at 16:28
  • Thanks, that link helped. Commented Jan 12, 2021 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.