WordPress Adding Pagination To Category Archive Page Listings

To display paging on the bottom of your category (taxonomy) listings which are displayed using the archive.php page, add the following code where you would like the paging to appear.


<?php the_posts_pagination(); ?>

This will automatically create pagination on for your category listings.  The output can be styled using CSS by targeting the output elements similar to those shown below.

<div class="nav-links">
<a class="prev page-numbers" href="https://usewordpress.com/category/snippets/page/4/">Previous</a>
<a class="page-numbers" href="https://usewordpress.com/category/snippets/">1</a>
<span class="page-numbers dots">…</span>
<a class="page-numbers" href="https://usewordpress.com/category/snippets/page/4/">4</a>
<span aria-current="page" class="page-numbers current">5</span>


You can also pass arguments to the the_posts_pagination() function to customize the output to your needs.  You can view a list of available arguments on the WordPress function reference page.

Available for Amazon Prime