Support » Plugin: kk Star Ratings » [Plugin: kk Star Ratings] Trying to do manual loop of $top_rated_posts. Empty array.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Kamal Khan

    (@bhittani)

    It should work.

    Can you paste the code snippet so that I can have a look.

    Kamal,
    Thanks for your response! It was my mistake- I hadn’t replaced $total with a value. As soon as I did, the query worked. For anyone trying to do a similar simple top-rated posts query, here is my code:

    <?php if(function_exists('kk_star_ratings_get')) : $top_rated_posts = kk_star_ratings_get(5); endif; 
    
    foreach($top_rated_posts as $post) {
    
       $post_id = $post->ID;
       $queried_post = get_post($post_id);
    
       echo "<li id='rated-post-id-" . $post_id . "'>";
       echo "<a href='".get_permalink($post_id)."'>";
       echo get_the_post_thumbnail($post_id, 'thumbnail');
       echo "</a><a href='".get_permalink($post_id)."'>".$queried_post->post_title."</a>";
       echo " <span style='font-size:10px;'>(".$post->ratings."/5)</span>";
       echo "<p class='excerpt'>";
       echo substr($queried_post->post_content, 0, 200);
       echo "&hellip;</p>";
       echo "</li>";
    }?>
    Plugin Author Kamal Khan

    (@bhittani)

    Thank you 🙂

    Thank you for you code, Adam! was exactly what I was looking for. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: kk Star Ratings] Trying to do manual loop of $top_rated_posts. Empty array.’ is closed to new replies.