WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination content not changing using WP_Query (2 posts)

  1. frogger_box
    Member
    Posted 10 months ago #

    I really hope that someone can help me with this as I've been searching for hours and it's driving me nuts..

    I am trying to limit the number of posts using WP_Query, this is my code

    <?php
    	$paged = (get_query_var('page')) ? get_query_var('page') : 1;
    
    	$args = array('posts_per_page' => '2' , 'page' => $paged  ); 
    
    	$wp_query = new WP_Query($args); ?>
    
    	<?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
            /// stuff in the loop
    
    <?php endwhile; ?>
    
    	<?php if ( function_exists( 'bones_page_navi' ) ) { ?>
    	      <?php bones_page_navi(); ?>
    	<?php } else { ?>
    	<nav class="wp-prev-next">
    		<ul class="clearfix">
    			<li class="prev-link"><?php next_posts_link( __( '&laquo; Older Entries', 'bonestheme' )) ?></li>
    			<li class="next-link"><?php previous_posts_link( __( 'Newer Entries &raquo;', 'bonestheme' )) ?></li>
    		</ul>
               </nav>
    	<?php } ?>
    	<?php wp_reset_postdata(); ?>
    	<?php else : ?>

    The pagination links show fine but when I click them the content doesn't change. The URL is correct, however. I have changed the reading settings max posts to 2 but still get the same problem.

    Any help would be greatly appreciated.

  2. frogger_box
    Member
    Posted 10 months ago #

    I'm an idiot.. the 2 was in a string..

Reply

You must log in to post.

About this Topic