WordPress.org

Ready to get started?Download WordPress

Forums

Next/Previous links showing same posts (13 posts)

  1. Geetar
    Member
    Posted 5 years ago #

    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

  2. itsmatt
    Member
    Posted 4 years ago #

    I am also having this problem.

  3. 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?

  4. Geetar
    Member
    Posted 4 years ago #

    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.

  5. 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.

  6. krembo99
    Member
    Posted 4 years ago #

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

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

  8. Geetar
    Member
    Posted 4 years ago #

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

  9. 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?

  10. krembo99
    Member
    Posted 4 years ago #

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

  11. Geetar
    Member
    Posted 4 years ago #

    Thanks krembo99, i'll try it.

  12. Geetar
    Member
    Posted 4 years ago #

    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>
  13. ReinoNL
    Member
    Posted 4 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.