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?
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?
MANY WAYS depending on what you want ..
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.
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 THIS THIS and THIS again ...
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...
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.
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..
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/
This topic has been closed to new replies.