Server-side sorting of posts

I have seen on some websites that you can sort posts server-side by passing in some queries like so: domain.com/?sort=date or domain.com/?sort=name

How would I do this with WordPress posts on a page?

Related posts

Leave a Reply

1 comment

  1. The display of posts is controlled by WordPress Loop. It has a lot of possible arguments, but they are rarely exposed in URL (especially if using pretty permalinks).

    But it is possible to make use of arguments by manually adding them to URL.

    For sorting see Orderby Parameters. Your example would be something like:

    domain.com/?orderby=date
    domain.com/?orderby=title