Get Sum of custom fields
-
hey there, i’ve posted this question yesterday with 2 others aswell. so instead of waiting for a complete solution, let’s just go through everything one by one. actually, i don’t want anyone to do everything for me ?? i just need someone who can take me to the right way ??
so here’s my problem.
i have added 7 custom fields all with digital values. they are ratings like quality, design, usability etc
is there a way to get the sum of these fields to be named as total_rating? actually, making a sum with php is easy, but I can’t call them like this in the top25 list.
so what I exactly need…
a solution so i can use this$querystr = “SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = ‘rating_total’ AND wposts.post_type = ‘post’ ORDER BY wpostmeta.meta_value+0 DESC LIMIT 3”;
$pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts):
foreach ($pageposts as $post):
setup_postdata($post);
?>as you can see the ratings are taken with wpostmeta.meta_key = ‘rating_total’
however, adding anything to this code only messes up everthing ??i appreciate any help!
thanks in advance
- The topic ‘Get Sum of custom fields’ is closed to new replies.