WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to loop all the latest post from all the categories but it is displaying only a post from single category. Below is the code that I am using.

<?php while (have_posts()) : the_post(); ?>
<li <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <a class="wpn_title" href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    <div class="wpn_info">
        <?php echo get_avatar( get_the_author_email(), '40' ); ?>
        by <?php the_author_posts_link() ?><br />
        Posted <?php the_time('F jS, Y \a\t g:i a') ?>
    <div class="wpn_post">
        <?php wpn_content_limit(get_the_content(),500); ?>
    <div class="wpn_bottom">
        <a class="wpn_comments" href="<?php the_permalink() ?>#comments"><strong><?php comments_number(__('0'), __('1'), __('%')); ?></strong> Comments</a>
        <a class="wpn_continue" href="<?php the_permalink() ?>">Continue Reading</a>
<?php endwhile; ?>


It looks like the issue is caused by the following code which I have placed on top of index.php. Is there something I missed?

<ul class="list">
                    <?php query_posts('r_sortby=highest_rated&r_orderby=DESC&showposts=4&cat=9') ?>
                        <?php while (have_posts()) : the_post(); ?>
                                <span class="num"><?php $key="ratings_users"; echo get_post_meta($post->ID, $key, true); ?></span>
                                <a class="img" href="<?php echo get_permalink(); ?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'top-score-thumb' ); } ?></a>
                                <div class="text"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_titlesmall('', '...', true, '20') ?></a></div>
                    <?php endwhile; ?>
share|improve this question
up vote 2 down vote accepted

sorry guys, I was suppose to end query_posts with <?php wp_reset_query(); ?> . This solved the issue.


share|improve this answer
Please post the complete correct code. It'll help noobs :) – its_me Jul 7 '12 at 17:15

Your Answer


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.