• Resolved sneakykitty

    (@sneakykitty)


    I have two categories on my page. I want the “comic” category to always show up at the top of the page, but only the most recent post in that category. I want the “news” category to show below the comic category, and i want to show 4 news posts.

    I’ve done this by setting up multiple loops. However, this has effectively broken previous page navigation. When i click the “Previous Entries” link for the first loop, it takes me to a Page 2 sort of deal that effectively shows me the same things. There are two comics up there, so when you click “previous entries”, i’d love for it to actually show you the one just before it.

    The page in question is a sandbox page that i use to test stuff before i make it live on my Actual Page.

    Can someone please take a look at the code i’m using and make some suggestions as to what might resolve this issue?

    <!-- Start first loop -->
    <?php query_posts('category_name=comic&showposts=1'); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post">
    				<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 
    
    				<!--
    				<?php trackback_rdf(); ?>
    				-->
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    <!-- End first loop -->
    
    	<?php rewind_posts(); ?>
    
    <!-- Start second loop -->
    <?php query_posts('category_name=news&showposts=4'); ?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post">
    				<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 
    
    				<!--
    				<?php trackback_rdf(); ?>
    				-->
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    <!-- End second loop -->

    (Disclaimer: I have looked at a few other posts on the support forums before posting here, but either i wasn’t implementing the various fixes correctly (i am something of a PHP noobwaffle), or they just didn’t resolve my particular issue. So please don’t tell me to go read other posts, because i have already done so and am still unable to resolve the issue.)

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘multiple loops break previous page navigation’ is closed to new replies.