• I’m running a two loop site here. What we want is to have the five latest posts under the category “News” show up in the left column and the two latest posts under the category “Writing” show up in the right column. The problem is that every time you post something to the site, you have to edit the template to make sure the right number of posts are displayed. For example, if you post a new News item, it displays it at the cost of a Writing item until you increase the showposts value for the Writing loop. It’s like the showposts values in the queries are interfering with eachother. Here’s the code for the loops:

    <div id="news">
    
    <h1>Highlands News</h1>
    
    <?php query_posts('showposts=8'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php if (in_category('1')) continue; ?>
    
    <h2 id="post-<?php the_ID(); ?>">
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" >
    <strong class="highlight"><?php the_time('F jS, Y') ?></strong> - <?php the_title(); ?></a> </h2>
    
    <?php   endwhile;
    endif; ?>
    </div>
    
      <div id="writing"> <h1>Highlands Writing</h1>
    <?php rewind_posts(); ?>
    
    <?php query_posts('showposts=5'); ?><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php if (in_category('4')) continue; ?>
    
    <h2 id="post-<?php the_ID(); ?>">
    
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    "<?php the_title(); ?>" by <?php the_author_firstname() ?> </a></h2>
    
    <small><?php the_time('F jS, Y') ?> </small>
    
    <?php      the_excerpt();
       endwhile;
    endif; ?>
    
    </div>

    You can see that we’ve had to bump up the showposts values several times in order for it to display right, but this is obviously not ideal. Can anyone tell me how to fix this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘help with two loop site – limiting posts’ is closed to new replies.