WordPress.org

Support

Support » Themes and Templates » Next/Previous links showing same posts

Next/Previous links showing same posts

  • Clicking Next/Previous links goes to the next page, however it always show the same posts.

    I’ve seen this problem in other threads, but none of the solutions seems to work, at least for me.

    home.php code is:

    <?php get_header(); ?>
    
    <div id="homepage">
    
    	<div id="contentleft">
    
    		<div class="postarea">
    
            <?php /*Check for the 'gallery_styles' function. if it's there, then include it. If not, do nothing*/ ?>
    		<?php if (function_exists('gallery_styles')) : ?>
    
            <div id="fcg">
    
                <?php include (ABSPATH . '/wp-content/plugins/content-gallery/gallery.php'); ?>
    
             </div>
    
    		 <?php endif; ?>
    
    			<div class="aheadline">
    
    				<h3>Featured News</h3>
    
    			</div>
    
    			<div style="clear:both;"></div>
    
    				<!--This is where the thumbnails are found for the featured page  - note the custom field name for this image is "thumbnail".-->
                    <!--Replace cat=1 with the Category ID you want to display in this section.-->
    
    				<?php $recent = new WP_Query("showposts=20"); while($recent->have_posts()) : $recent->the_post();?>
    				<?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
    				    <a href="<?php the_permalink() ?>" rel="bookmark"> </a>
    				<?php else: ?>
    				   	<a href="<?php the_permalink() ?>" rel="bookmark"> </a>
    				<?php endif; ?>
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    				<?php the_content_limit(400, "[Read more]"); ?>
    
    				<div style="border-bottom:1px dotted #BBBBBB; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
    
    				<?php endwhile; ?>					
    
    		<div class="pagination">
    
    				<div class="palignleft"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    				<div class="palignright"><?php next_posts_link('Next Page &raquo;') ?></div>
    
    			</div>
    
    		</div>
    
    	</div>
    
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    
    </div>
    
    <!-- The main column ends  -->
    
    <?php get_footer(); ?>

    Thanks in advance

Viewing 12 replies - 1 through 12 (of 12 total)
  • itsmatt

    @itsmatt

    I am also having this problem.

    Moderator Mark Ratledge

    @songdogtech

    Forum Moderator

    Is this from a theme or is this coded from scratch? if a theme, have you looked at the theme developers website?

    Are you sure you have more than 20 posts in order to show new posts on the next page?

    Hi songdogtech, thanks for your reply, I have more than 9000 posts. The theme is Revolution two Streamline (The Beta version was open source and free downloadable). I’ve been trying with plugins different codes etc without any luck.

    Now i’m using: http://www.mysite.com/2009/page/2/ in order to display the old posts.

    Moderator Mark Ratledge

    @songdogtech

    Forum Moderator

    I think the problem is you’re running a new query without the main loop. Try setting showposts to 1, which means all posts, and then use something like Custom Query String to set the number of posts that show up and also to fix the next/previous links. It works with 2.8.4; I use it on several sites. Maybe that will get around some sort of bug in the theme.

    krembo99

    @krembo99

    It is showing always the same post simply because it is NOT INSIDE the loop.
    Those tags can not work outside the loop.

    Moderator Mark Ratledge

    @songdogtech

    Forum Moderator

    You’re right; try putting the main loop back in place. You can select how many posts are shown by default, or modify it with CQS.

    Thanks guys, so what I must change on the code above at home.php?

    Moderator Mark Ratledge

    @songdogtech

    Forum Moderator

    I’d try getting a fresh copy of the theme and see if it has the main WP loop in it so you can get it in the right place. I assume you’ve modified the theme code you posted above?

    krembo99

    @krembo99

    what you have to do is just to put it INSIDE the loop…
    BEFORE the <?php endwhile;>

    Thanks krembo99, i’ll try it.

    Hi songdogtech, no I didn’t modify the theme, I just added:

    <div class="pagination">
    
    				<div class="palignleft"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    				<div class="palignright"><?php next_posts_link('Next Page &raquo;') ?></div>

    if you are running a new query like:

    <?php
    query_posts(array(
    'cat' => 4,
    'showposts'=>'5',
    ));
    ?>

    you can fix the next and prev links bij adding:
    ‘paged’=> get_query_var(‘paged’) ? get_query_var(‘paged’) : 1,

    So it will be like this:

    <?php
    query_posts(array(
    'paged'=> get_query_var('paged') ? get_query_var('paged') : 1,
    'cat' => 4,
    'showposts'=>'5',
    ));
    ?>

    Cheers!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Next/Previous links showing same posts’ is closed to new replies.