Support » Fixing WordPress » Category Loop: how do I specify # of posts per page?

  • Resolved sparklogix


    It seems like I could just use a post query but that screws up everything. I’m using a category loop (in the loop.category.php) file and this is the code in that file:

    <?php $i=0;?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <?php  $i++;?>
    <?php if($i%4==0){ $class='none';} else $class='';?>
    <li class="<?php echo $class;?>"><a href="<?php the_permalink();?>">
    <?php if (has_post_thumbnail( $post->ID )) : ?>
    <?php  $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
    <img src="<?php echo $image[0]; ?>" width="130" height="131" alt="" />
    <?php endif;?></a>
    <span><a href="<?php the_permalink();?>"><?php the_title();?></a></span>
    <?php endwhile;?>

    I didn’t write this, it was built into the theme someone else had edited. I’m not sure how to modify it to make 20 posts show per page with pagination at the bottom. Well, I have gotten 20 posts on the page, but not without screwing up everything else. Thoughts?

Viewing 3 replies - 1 through 3 (of 3 total)
  • What is your “Settings -> Reading -> Blog pages show at most” value? Does altering this (try 20) change the number shown in your loop?

    You don’t even know how stupid I feel right now. I’m too busy looking for difficult solutions to even notice the simple things.

    Thanks goodness for a forum that helps the slow folks like me. Now I just need to get pagination in there and I’m good to go. Thanks so much!

    No problem, glad you got it sorted. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category Loop: how do I specify # of posts per page?’ is closed to new replies.