I am using my home page to show all my posts. Therefore I use WP_Query
.
When I click on the pagination, the url changes but not the page content.
This is my code,
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'page' => $paged );
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post(); ?>
<div class="home-post">
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="thumb-img">
<img src="<?php the_post_thumbnail(); ?>" alt="" />
<div class="thumb-hover"></div>
</div>
<!--/ thumb image -->
<div class="post-excerpt">
<?php the_excerpt(__('(more…)')); ?>
</div>
<!--/ post excerpt -->
<a class="readmore" href="<?php the_permalink(); ?>">Continue Reading</a>
</div>
<!--/ home post -->
<?php endwhile; ?>
<div class="home-pagination">
<!-- then the pagination links -->
<?php next_posts_link( '← Older posts', $wp_query ->max_num_pages); ?>
<?php previous_posts_link( 'Newer posts →' ); ?>
</div>
'page'
to'paged'
in the query arguments.$wp_query
as a local variable, this breaks the main query object which in turn breaks many many other functions