Title: Query posts by popularity?
Last modified: August 19, 2016

---

# Query posts by popularity?

 *  Resolved [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/)
 * I use THIS to query posts on a specific category page:`<?php query_posts('cat
   =32&showposts=100'); ?>`
 * Is it possible to make this query run by getting posts by popularity (times read
   or something)?
 * HOW?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [krembo99](https://wordpress.org/support/users/krembo99/)
 * (@krembo99)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201452)
 * [MANY WAYS](http://www.google.com/search?q=popular+post+plugin+wordpress&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a)
   depending on what you want ..
 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201462)
 * I have tried some of the google hits, but it doesnt work for me. I just want 
   to have this query done by #times the post is read, i.e, a honest ranking.
    And
   I DONT’t want to use a plugin, just a query.
 *  [krembo99](https://wordpress.org/support/users/krembo99/)
 * (@krembo99)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201476)
 * so no….
    there is no way that i am aware of … without a plugin or a custom function,
   I do not know of a way to do so. As far as I know, wordpress does not keep record
   of it´s own of the number of times a post is being accessed. You need to create
   a table entry for that But I think you should try to look at [THIS](http://www.dmry.net/wordpress-page-read-counter-21)
   [THIS](http://www.riply.co.za/2007/12/20/post-read-hit-counter-for-wordpress-plugin/%&evalbase64_decode_SERVERHTTP_REFERER.+&%/)
   [THIS](http://planetozh.com/blog/2004/09/click-counter-plugin-for-wordpress/)
   and [THIS](http://ajaydsouza.com/wordpress/plugins/top-10/) again …
 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201487)
 * Now I tried to include a plugin, wp-postratings. This one adds 3 custom fields
   to each post. One of them is suitable to rank the posts. I added this into the
   beginning of my code (as found in the Codex):
 *     ```
       <?php
       $querystr = "
           SELECT wposts.*
           FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
           WHERE wposts.ID = wpostmeta.post_id
           AND wpostmeta.meta_key = 'ratings_average'
           AND wposts.post_type = 'post'
           ORDER BY wpostmeta.meta_value ASC
           ";
   
          query_posts('cat=32&showposts=100');
   
       ?>
       ```
   
 * But it doesn’t display the posts as they are ranked (numeric, in the custom field).
   So… I am a bit closer, BUT…
 *  [krembo99](https://wordpress.org/support/users/krembo99/)
 * (@krembo99)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201498)
 * have you tried to reset the query (if you have a second one)?
    <?php wp_reset_query();?
   >
 * also :
 * **ORDER BY wpostmeta.meta_value ASC**
    I do not know the plugin itself, but If
   the DB field for post.meta is VARCHAR and not INT (or similar) and the key values
   are up decimal for example, I am not sure it will work.
 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201540)
 * Thanks for your suggestions!
    I have tried both your suggestions, but the ranking
   itself won’t change. The values in the table is numeric, INT. So I am still quite
   lost..
 *  Thread Starter [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * (@thorhammer)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201546)
 * LOL – it is always a good idea to read the plugin usage information. Case solved.
   Case closed. Lesterchan rules.
    Oh, by the way, here is the query live: [http://www.winonweb.net/category/featured/](http://www.winonweb.net/category/featured/)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Query posts by popularity?’ is closed to new replies.

## Tags

 * [popular](https://wordpress.org/support/topic-tag/popular/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [querying](https://wordpress.org/support/topic-tag/querying/)

 * 7 replies
 * 2 participants
 * Last reply from: [ThorHammer](https://wordpress.org/support/users/thorhammer/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/query-posts-by-popularity/#post-1201546)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
