Show highest rated posts ONLY if there are 10 total votes cast
I am using the following code to display the most recent posts on a part of my site using this code:
<tr> <?php $args = array( 'numberposts' => 4, 'meta_key' =>'_kksr_avg', 'orderby' =>'meta_value', 'order'=> 'DES','post_type' => 'tsv_userpost'); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <?php $postscast = get_post_meta ($post->ID, _kksr_casts, true); ?> <td> <a href="<?php echo get_permalink (); ?>"> <?php if ( has_post_thumbnail()): the_post_thumbnail( 'missed-thumb', array( 'class' => 'missed-thumb' ) ); endif; ?> </a> <span class="date"> <?php the_time('M j'); ?> </span> <span class="rating"> | <?php echo get_post_meta($post->ID, _kksr_avg, true); ?>/5 Stars (rated by <?php echo $postscast ?> people) </span> <br /> <span class="title"> <a href="<?php echo get_permalink (); ?>"><?php echo get_the_title(); ?></a> </span> <?php endforeach; ?> </td>
I want to change this so that it only shows posts if they have at least 10 or more total votes casts (in order to prevent posts with only 1 vote of 5 starts from jumping straight to the top.)
I’m sure there’s some sort of if statement involved, but I can’t quite figure out how to get it right.
Can anyone help?
- The topic ‘Show highest rated posts ONLY if there are 10 total votes cast’ is closed to new replies.