I’m using wp-postratings to rate posts which stores the rating as a custom meta value ratings_score
. It gives you the option to use r_sortby
to order the loop by highest rated but I want to give it a trending feel by dividing the $ratings_score” by how old the post is in days. So something like this..
$ratings_score = get_post_meta($post->ID,'ratings_score',true);
orderby = $ratings_score / days ago
How can I accomplish this?
You could do this by sorting on a calculated factor. Dividing the rating by the days gives a good starting point:
You can balance this to your needs by multiplicate the variables (rating and day) with any factor you like.
There are to ways to implement such a factor: