Would be great if you could point me in the right direction with this:

Be default, I want my blog to show posts in the traditional newest first -order, however, it would be good if my readers could reverse the order sometimes for themselves. A random post would be good too, but if you can help me to use this template code

<?php if(have_posts()) : global $query_string;
query_posts( $query_string . '&order=DEC' ); ?>

to change the order, that would be cool. I know DEC/ASC etc, but how do I implement several of them on a template rather than be stuck with just one?

Do I have to create a new template file for each, or perhaps have a drop down menu... on that - I'm not much of a coder, but I can fiddle with some easy stuff.

What I would like to see do is to create a

Order post by: Oldest first - Random - Alphabetical

-selection at the top of the index.php template, I think you'll catch my meaning.

Does that make sense? This shouldn't be hard, right? I can't even find a plugin to do this. :/



1 Answer 1


Just have a dropdown with options for sorting order and when user changes the option in dropdown, make an ajax call(post the selected order) and fetch posts as per user selected order and populate the data after getting response.

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.