Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
Please consider accepting answers to questions you've posted previously or offering more details in the form of an edit explaining why current answers are insufficient. A 0% accept rate isn't very encouraging when you ask others for help ... –  EAMann Dec 7 '10 at 22:02

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
    
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 '10 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 '10 at 23:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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