WordPress Post Sorting?

I to allow my users to sort the list of wordpress posts by Title, Date added, Comments, Rating etc. These will all be buttons or links at the top of the list (kinda like table view sorting)

However, I have no PHP experience and only know a few basics. How would I achieve this? I currently use the following line to sort my posts by name ASC:

Read More
<?php query_posts( $query_string . "&orderby=title&order=ASC" ); ?>

I was personally thinking of the following solution: orderby=VARIABLE1&order=VARIABLE2

Where VARIABLE1 would be set to title by default and VARIABLE2 would be set ASC by default. However I don’t know if this is the best solution, and I know even less on how to achieve this.

Thanks for any future help!

Related posts

Leave a Reply

2 comments