Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

http://wp.tutsplus.com/tutorials/how-to-create-a-simple-post-rating-system-with-wordpress-and-jquery/

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)

    <?php
/*
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(); ?>

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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>';
    the_title();
    echo '</li>';
endwhile;
endif;
echo '</ul>';
share|improve this answer
    
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. –  Frank Morrison Sep 1 '12 at 16:03
    
I was so chuffed that it works...I forgot to say thanks! So thanks Rizqy, its appreicated. –  Frank Morrison Sep 1 '12 at 17:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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