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'm using the following code to display posts on my category page but would like to carry the same format through on to the second page of the category as at the moment it moves to the second page but doesn't show the older posts.

       <?php query_posts('showposts=3&cat=1461');
            while (have_posts()) : the_post();
            echo "<div class=column-post>";
            echo "<div class=category-thumb><a href=";
            echo get_permalink();
            echo ">";
            the_post_thumbnail(array (185,152));
            echo "</a></div>";
            echo "<div class=category-title><a href=";
            echo get_permalink();
            echo ">";
            the_title(); 
            echo "</a></div>";
            echo "<div class=category-desc>";
            the_excerpt();
            echo "</div>";
            echo "<div class=category-more><a href=";
            echo get_permalink();
            echo ">";
            echo "<img src=";
            bloginfo('template_directory');
            echo "/images/more.png>";
            echo "</a></div>";
            echo "</div>";
            endwhile;?>  </div>
  <div class="divider"></div>
  <div class="3-column-holder">
    <?php query_posts('showposts=3&offset=3&cat=1461');
            while (have_posts()) : the_post();
            echo "<div class=column-post>";
            echo "<div class=category-thumb><a href=";
            echo get_permalink();
            echo ">";
            the_post_thumbnail(array (185,152));
            echo "</a></div>";
            echo "<div class=category-title><a href=";
            echo get_permalink();
            echo ">";
            the_title(); 
            echo "</a></div>";
            echo "<div class=category-desc>";
            the_excerpt();
            echo "</div>";
            echo "<div class=category-more><a href=";
            echo get_permalink();
            echo ">";
            echo "<img src=";
            bloginfo('template_directory');
            echo "/images/more.png>";
            echo "</a></div>";
            echo "</div>";
            endwhile;?>
            </div>  <div class="divider"></div>
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

First make sure you've set your posts per page to 6 in the Reading settings - as I can see you're displaying 2 columns of 3 posts. Then you need to add the page variable to the query_posts attributes, by adding this before you query posts:

$paged = (get_query_var('page')) ? get_query_var('page') : 1;

and then changing the query_posts function calls to:

query_posts('showposts=3&cat=1461&paged='.$paged);

and

query_posts('showposts=3&offset=3&cat=1461&paged='.$paged);

You'll also want to cheange you links to the previous and next pages by using something like the next_posts and prev_posts tags or you can simply make it yourself by adding /page/2 (for example) to the end of the category permalink - if you're using pretty URLs of course.

It would probably be a good idea to check that you've got more than 3 posts to display before running the query for the second column too.

share|improve this answer
add comment

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.