My pagination isn't working for my archive.php, which I'm using as a template for my blog post categories links.
<div class="row">
<?php $the_query = new WP_Query( array(
'posts_per_page'=>1,
'order'=>'DESC',
'paged' => get_query_var('paged') ? get_query_var('paged') : 1)
); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div class="col-lg-4 col-md-4 col-sm-12 blog-content text-styles">
<a class="blog-post-area" href="<?php the_permalink() ?>">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail('main-news-thumbnail-uncropped', array('class' => 'img-fluid post-image'));
} ?>
<h3 class="post-title"><?php the_title() ?></h3>
<?php the_excerpt() ?>
<a class="blog-post" href="<?php the_permalink() ?>">Read More</a>
</a><!--End Link-->
</div><!--End Columns-->
<?php endwhile; ?>
</div><!--End Row-->
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="pagination">
<?php
$big = 999999999; // need an unlikely integer?>
<?php echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
?>
<?php wp_reset_postdata();?>
</div><!--End Pagination-->
</div><!--End Columns--->
</div><!--End Row-->
Any ideas? I can't figure it out!
$the_query = new WP_Query
? For the main templates you should just be usinghave_posts()
andthe_post()
without$the_query->
.