WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination Issue Using query_posts (5 posts)

  1. JRiley21
    Member
    Posted 3 years ago #

    Hi all. :)

    Ok, so I've spent all day looking at how to fix my pagination issue. Basically, when I click on 'older' or 'newer' posts, it just displays the first page again.

    I got a decent understanding of the issue with this thread: Here (Tried the suggestions, still didn't work).

    I also gave this a shot: Here (Also didn't work).

    Here's the code I'm using in that section: Here

    Can someone help me adjust this code so that the pagination works correctly!? This has been a major headache.

    Thanks! :)

  2. MichaelH
    Member
    Posted 3 years ago #

    At the very least, this line

    <?php query_posts('cat=1&showposts=5'); ?>

    should be

    <?php query_posts('cat=1&showposts=5&paged=' . $paged); ?>
  3. JRiley21
    Member
    Posted 3 years ago #

    Michael - That's exactly what I needed, thanks a TON! You're a life saver. :)

  4. michaeldante
    Member
    Posted 3 years ago #

    what php page are you pasting this code at? I have the classipress theme and clicking on page 2 changes the url but not the results and wanted to know where this code goes at.
    thanks

  5. mxpimp47
    Member
    Posted 3 years ago #

    ive tried that and i cant override my default settings. the first page displays correctly, but when you click next page it shows the remaining posts and not the post limit i set. and in the title of the browser it says "pages not found". i have googled and googled and searched wordpress.org and read many others solutions. which none of them fix my issue. could you please tell me what i might be leaving out. here is my code -

    <strong><?php get_header();  ?> 
    
    <?php get_sidebar(); ?>  
    
    <?php query_posts('cat=3&showposts=2&paged=' . $paged); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<div class="recent-news">
    
    	<div class="post-thumbnail">
    	<?php the_post_thumbnail(); ?>
    	</div><!--end post-thumbnail-->
    	<div class="latest-news">
    	<div class="post-title"><h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2></div>
    		<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,40); ?>... <a href="<?php the_permalink(); ?>">Read More</a></p>
    		 <div class="datetime"><?php the_author(); ?> - <?php the_time('l, F j, Y G:i'); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></div>
    		</div><!--end latest-news-->
    	</div><!--end recent-->
    
    <?php comments_template(); // Get wp-comments.php template ?>
    
    <?php endwhile; else: 
    
    ?>
    
    <h2>Woops...</h2>
    
    <p>Sorry, no posts we're found.</p>
    
    <?php endif; ?>
    <div class="clearfloat"></div>
    
    <div id="post-nav"><p align="center"><?php posts_nav_link(); ?></p></div><!--end post-nav-->
    
    </div><!--end wrapper-->
    
    <?php get_footer(); ?></strong>

    Thanks in advance for any help!

Topic Closed

This topic has been closed to new replies.

About this Topic