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?


1 Answer 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:

  • Didn't know this was possible on the public side. Can the same be done with number of posts shown? And can the two be mixed together easily, so for example sort them by date and show 20 items.
    – Cameron
    Dec 7, 2010 at 23:35
  • Yeah, this is somewhat underknown trick. :) Arguments, related to number of posts, seem to be ignored if used this way. Most probably Loop overwrites them with blog's settings.
    – Rarst
    Dec 7, 2010 at 23:51

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.