[resolved] Category Loop: how do I specify # of posts per page? (4 posts)

  1. sparklogix
    Posted 5 years ago #

    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?

  2. David Gwyer
    Posted 5 years ago #

    What is your "Settings -> Reading -> Blog pages show at most" value? Does altering this (try 20) change the number shown in your loop?

  3. sparklogix
    Posted 5 years ago #

    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!

  4. David Gwyer
    Posted 5 years ago #

    No problem, glad you got it sorted. :)

Topic Closed

This topic has been closed to new replies.

About this Topic