• I have a special template for a page on my site. Basically I want to display 3 posts and have previous and next links so users can scroll through older posts.

    It will display three posts, but the previous and next links don’t work. Previous just shows the same three posts.

    <?php query_posts('cat=6&showposts=3'); ?>
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    			<ul class="pmeta">
    				<li>Posted by <?php the_author() ?></li>
    				<li>On <?php the_time('F j, Y') ?></li>
    				<li><br /><?php the_category(', ') ?></li>
    				<?php if (function_exists('the_tags')) { the_tags('<li>Tags ', '</li>'); } ?>
    				<li><br /><?php comments_popup_link('No Comments', '1 Comment', '% Comments' );?></li>
    				<?php edit_post_link('Edit', '<li>', '</li>'); ?>
    			</ul>
    			<div class="apost">
    				<h2 id="post-<?php the_ID(); ?>">
    <?php if (function_exists('get_cat_icon')) get_cat_icon('small=false'); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<div class="pmain">
    					<!-- spost -->
    
    <?php the_content('Read more...'); ?>
    
    					<!-- epost -->
    				</div>
    <?php if ($count==1) { ?>
    
    <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) BELOW -->
    <script type="text/javascript"><!--
    
    /* 468x60, created 4/26/08 */
    
    <script type="text/javascript"
    
    src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
    
    </script>
    
    <!-- PLACE YOUR 468x60 ADSENSE CODE (OR BANNER) ABOVE -->
    
    <?php } ?>
    <?php $count = $count + 1; ?>
    
    			</div>
    
    			<div class="extra"></div>
    <?php endwhile; ?>
    
    			<div class="lead">
    				<span class="ppre"><?php next_posts_link('&laquo; Previous Posts') ?></span>
    				<span class="pnex"><?php previous_posts_link('Next Posts &raquo;') ?></span>
    			</div>
    <?php else : ?>
    			<div class="apost">
    				<h2 class="subh">Oops!</h2>
    				<p class="nopost">Sorry, but you are looking for something that isn't here.</p>
    			</div>
    <?php endif; ?>
    		</div>
    	</div>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Search the forums. By default a custom query breaks the next/prev navigation.

    There were quite a number of posts suggesting different fixes.

    Thread Starter clockworkjoe

    (@clockworkjoe)

    Found a lintk to weblog tools collection that helped. However, two problems

    1. The prev and more links are reversed.

    2. The sidebar is totally messed up.

    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(‘cat=6&showposts=3′.’&paged=’.$paged);
    ?>

    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <ul class=”pmeta”>

    • Posted by <?php the_author() ?>
    • On <?php the_time(‘F j, Y’) ?>
    • <?php the_category(‘, ‘) ?>
    • <?php if (function_exists(‘the_tags’)) { the_tags(‘

    • Tags ‘, ‘
    • ‘); } ?>

    • <?php comments_popup_link(‘No Comments’, ‘1 Comment’, ‘% Comments’ );?>
    • <?php edit_post_link(‘Edit’, ‘

    • ‘, ‘
    • ‘); ?>

      <div class=”apost”>
      <h2 id=”post-<?php the_ID(); ?>”>
      <?php if (function_exists(‘get_cat_icon’)) get_cat_icon(‘small=false’); ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2>
      <div class=”pmain”>
      <!– spost –>

      <?php the_content(‘Read more…’); ?>

      <!– epost –>
      </div>
      <?php if ($count==1) { ?>

      <!– PLACE YOUR 468×60 ADSENSE CODE (OR BANNER) BELOW –>
      <script type=”text/javascript”><!–

      /* 468×60, created 4/26/08 */

      google_ad_width = 468;

      google_ad_height = 60;

      //–>

      </script>

      <script type=”text/javascript”

      src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;

      </script>

      <!– PLACE YOUR 468×60 ADSENSE CODE (OR BANNER) ABOVE –>

      <?php } ?>
      <?php $count = $count + 1; ?>
      </div>
      <div class=”extra”></div>
      <?php endwhile; ?>
      <div class=”lead”>
      <span class=”ppre”><?php previous_posts_link(‘« Previous’) ?></span>
      <span class=”pnex”><?php next_posts_link(‘More »’) ?></div>
      </span></div>
      <?php $wp_query = null; $wp_query = $temp;?>

    Thread Starter clockworkjoe

    (@clockworkjoe)

    You can see it at raillery.tv/blog

    Thread Starter clockworkjoe

    (@clockworkjoe)

    Anyone?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘special template page slightly broken – can’t figure out what’s wrong’ is closed to new replies.