Forums

special template page slightly broken - can't figure out what's wrong (5 posts)

  1. clockworkjoe
    Member
    Posted 4 years ago #

    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="http://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>
  2. moshu
    Member
    Posted 4 years ago #

    Search the forums. By default a custom query breaks the next/prev navigation.

    There were quite a number of posts suggesting different fixes.

  3. clockworkjoe
    Member
    Posted 4 years ago #

    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">

  4. Posted by <?php the_author() ?>
  5. On <?php the_time('F j, Y') ?>
  6. <?php the_category(', ') ?>
  7. <?php if (function_exists('the_tags')) { the_tags('

  8. Tags ', '
  9. '); } ?>

  10. <?php comments_popup_link('No Comments', '1 Comment', '% Comments' );?>
  11. <?php edit_post_link('Edit', '

  12. ', '
  13. '); ?>

    <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 468x60 ADSENSE CODE (OR BANNER) BELOW -->
    <script type="text/javascript"><!--

    /* 468x60, created 4/26/08 */

    google_ad_width = 468;

    google_ad_height = 60;

    //-->

    </script>

    <script type="text/javascript"

    src="http://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 previous_posts_link('« Previous') ?></span>
    <span class="pnex"><?php next_posts_link('More »') ?></div>
    </span></div>
    <?php $wp_query = null; $wp_query = $temp;?>

  14. clockworkjoe
    Member
    Posted 4 years ago #

    You can see it at raillery.tv/blog

  15. clockworkjoe
    Member
    Posted 4 years ago #

    Anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic