How to divide 2 meta_key (totalstarcount/totalstarvalue) in the wp_quey.

Q&ACategory: PluginHow to divide 2 meta_key (totalstarcount/totalstarvalue) in the wp_quey.
Anonymous asked 2 years ago

hi,
I have just installed your great plugin : “star-rating”.(http://paratheme.com/items/star-rating-five-star-rate-for-wordpress-post/)
My website is : http://www.voilapourquoijesuisfauche.fr/
I would like to order posts using your rating data. something like : http://www.voilapourquoijesuisfauche.fr/?tri=mieuxNote (/?rank=bestRated)
So I am using this wp_query code :
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$args = array(
‘meta_key’ => ‘totalstarvalue’,
‘orderby’ => ‘meta_value_num’,
‘order’ => ‘ASC’,
‘paged’ => $paged
);
$posts= query_posts($args);}

But I would like to order by rate ! ($rate =$starvalue/$totalstarcount). I did not manage to divide 2 meta_key (totalstarcount/totalstarvalue) in the wp_quey.
Thanks for your help !

1 Answers
Hasan Staff answered 2 years ago

Hi,  
Thanks for your post.
I have already replied your mail,
let me try first. I will reply with fixed code.  

#################################

Update: Please check following link for code sample. this might be help you.

https://github.com/paratheme/Query-Post-By-Star-Ratings—WordPress-Plugin
 
See there is file “query-post-by-ratings.php” you have to work with.
 
Hope you will solve.

#################
 
Please do not forget to give us five star rate at wordpress.org repo

https://wordpress.org/plugins/star-rating/
 
Thanks