Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top