• I am trying to display the previous posts and newer post links. What is wrong with this code? It works but if I rename my query $wp_query to anything else it won’t display the previous posts link on the first page.

    $temp = $wp_query; $wp_query= null;
    		$wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged);
    
    		while ($wp_query->have_posts()) : $wp_query->the_post();  ?><div id="postImage"><?php the_post_thumbnail(); ?></div>
        <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> </h3><span class="datePost"><?php  the_time('F j, Y') ;?></span>
    <?php
    the_excerpt();
    
     endwhile;
    
     if ($paged >1) { ?>
    
    		<nav id="nav-posts">
    			<div class="prev"><?php next_posts_link('&laquo; Previous Posts'); ?></div>
    			<div class="next"><?php previous_posts_link('Newer Posts &raquo;'); ?></div>
    		</nav>
    
    		<?php } else { ?>
    
    		<nav id="nav-posts">
    			<div class="prev"><?php next_posts_link('&laquo; Previous Posts'); ?></div>
    		</nav>
    
    		<?php } ?>

Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Displaying previous posts and newer posts links’ is closed to new replies.