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.

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).

Thanks

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Hi Amtik, I like the sound of Examples 2+3 :) –  Frank Morrison Jul 9 '12 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 –  Frank Morrison Jul 9 '12 at 20:25
    
Yes, It'll take some time to generate data and show. –  amit Jul 9 '12 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 Jul 9 '12 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 Jul 9 '12 at 20:57

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.