I was looking for a post rating system for a while, then I stumbled across a great tutorial:


I have it working (well, its recording clicks ok), but I cannot seem to get a "most liked" page. The tutorial said to use the following code, so made a page, but nothing appears (apart from logo, nav, footer etc)

Template Name: Top Rated
<?php get_header(); ?>    

<?php query_posts('meta_key=votes_count&orderby=meta_value_num&order=DESC&posts_per_page=10'); ?>

 <?php get_sidebar(); ?>

<?php get_footer(); ?>

Can anybody point me in the right direction? Thanks

EDIT: Thanks rizqy22, here is how the index displays posts:

`<a href="<?php the_permalink(); ?>"class="img_hover_trans"><?php the_post_thumbnail('featured-small'); ?></a>
      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>`

EDIT2: Made more progress, got the thumb, title etc displaying using the following code (just incase anybody else searches and finds my ramblings) <?php query_posts('meta_key=votes_count&orderby=meta_value_num&order=DESC&posts_per_p‌​age=10'); if (have_posts()) : while (have_posts()) : the_post(); ?> <a href="<?php the_permalink(); ?>"class="img_hover_trans"><?php the_post_thumbnail('featured-small'); ?></a> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php endwhile; endif; wp_reset_query(); ?>

1 Answer 1


Thats code just querying the posts by sorting it by meta value, but you have no loop for the posts to display. Add the loop after the query for something like this:

echo '<ul>';
if ( have_posts() ) : while ( have_posts() ) : the_post();
    echo '<li>';
    echo '</li>';
echo '</ul>';
  • Hi Rizqy, put in the code and BOOM...it works :) I will try to remember that (as you prob guessed, i dont know much about php haha). However, I was hoping to keep the same setup as my index (displaying the thumb/featured image, post title etc)...this is part of the code from the index. Im trying to combine the two, but just getting the white screen of death so far (I edited the original post with an exmample since I was running out of characters. Commented Sep 1, 2012 at 16:03
  • I was so chuffed that it works...I forgot to say thanks! So thanks Rizqy, its appreicated. Commented Sep 1, 2012 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.