Is it possible to have a drop down menu like youtube/demonoid that allows you to sort your index (and caterogy.php) blog posts by date/popularity/viewed)? I seen plugins for adding most popular widgets or pages, but I was hoping to be able to sort the users page they are looking at (be it the index page or a specific category).


1 Answer 1


Yes, we can sort Wordpress posts in different orders, You can do following sorts without installing plugins.

  1. sort post by date ( ascending / descending )
  2. Sort post by title (ascending / descending )
  3. Sort post by comment count ( ascending / descending ) -- These are just basic we can do even more using categories and tags etc

Wordpress already stores the comment count in database but they can not store view counts, ratings / popularity data by default. You must use some kind of plugins to do that. Those plugin will store related data in database and that data can be further used for query.

EXAMPLES - These queries don't need any plugins

  1. www.example.com/?orderby=date&order=asc
  2. www.example.com/?orderby=date&order=dsc
  3. www.example.com/?orderby=title&order=dsc
  4. www.example.com/?orderby=title&order=dsc
  5. www.example.com/?orderby=comment_count&order=asc
  6. www.example.com/?orderby=comment_count&order=dsc

Using custom field values for sorting as per View count / Popularity / Ratings, To work this you must install related plugin which store view count as a custom field value.

To Sort by View Count

first install this plugin - WP PostViews

EXAMPLES 3 - Links to sort by view count

  1. www.example.com/?v_sortby=views&v_orderby=dsc
  2. www.example.com/?v_sortby=views&v_orderby=asc

Update 1 - july/10

If you are using GD star rating plugin and want to sort the posts according to their ratings here is more info - http://www.gdstarrating.com/2009/07/03/how-to-reorder-posts/

HOW TO USE - Use links or buttons to those urls and then Wordpress will manage all other things.

  • Hi Amtik, I like the sound of Examples 2+3 :) Jul 9, 2012 at 20:06
  • I have wp-post-view installed and tried out those links. Does the plugin require time to rack up the views, because the links just take me to my index, but the posts are in the same order? You say in example 2, I can use custom field values for sorting, can you help me with that? Or point in the right direction? Thanks man Jul 9, 2012 at 20:25
  • Yes, It'll take some time to generate data and show.
    – Amit Kosti
    Jul 9, 2012 at 20:30
  • Hey, make sure you installed WP-postViews plugin with (123 review).. there are plenty of other plugins available. .. I just tested this plugin, and the examples I mentioned above for view count are working great.
    – Amit Kosti
    Jul 9, 2012 at 20:44
  • Using custom fields to sort posts - Suppose you running a movie review site and used custom fields to store review points into database. Using queries you can sort posts by asc/dsc order by their points. More info - gdstarrating.com/2009/07/03/how-to-reorder-posts
    – Amit Kosti
    Jul 9, 2012 at 20:57

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.