<?php // You have to change the post. $args = array( 'post_type' => 'wpbdp_listing', 'posts_per_page' => 6 ); $loop = new WP_Query( $args ); global $wpdb; $querystr = "SELECT wp_posts.*, rate.average_rating_users FROM wp_posts LEFT JOIN wp_gdsr_multis_data rate ON (wp_posts.ID = rate.post_id) Where wp_posts.post_status = 'publish' AND wp_posts.post_type = 'wpbdp_listing' AND rate.multi_id =2 ORDER BY rate.average_rating_users DESC LIMIT 10 "; $pageposts = $wpdb->get_results($querystr, OBJECT); if ($pageposts){ global $post; ?> <div id="ratings-widget-2" class="widget widget_ratings-widget"> <h3>Just Rated</h3> <ul> <?php foreach ($pageposts as $post){ setup_postdata($post); ?> <li> <a class="read_more" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php wp_gdsr_render_multi ($multi_set_id=2, $template_id=0, $read_only=true, $post_id=0, $stars_set="", $stars_size=0, $stars_set_ie6="", $avg_stars_set_ie6="oxygen_gif", $echo=false); ?> </li> <?php } ?> </ul> </div> <?php } ?>
Demo: http://myhairlog.com/