I got a blog page that displays 10 posts followed by a navigation with "next" and "previous". But our client needs a numbered pagination and not just a simple page navigation.
The posts output comes from a post query and not from the standard wordpress option.
<section class="blog">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 10,
'paged' => $paged,
'post_type' => 'post'
);
$cpt_query = new WP_Query($args);
?>
<?php if ($cpt_query->have_posts()) : while ($cpt_query->have_posts()) : $cpt_query->the_post(); ?>
<div class="beitrag">
<div class="beitrag-inhalt">
<p><?php the_excerpt(); ?></p>
</div>
<div class="weiterlesen">
<a href="<?php the_permalink(); ?>">Mehr Lesen</a>
</div>
</div>
<?php endwhile; endif; ?>
<nav>
<?php previous_posts_link( '<i class="fas fa-angle-left"></i> Vorherige Seite', $cpt_query->max_num_pages) ?>
<?php next_posts_link( 'Nächste Seite <i class="fas fa-angle-right"></i>', $cpt_query->max_num_pages) ?>
</nav>
</section>
How can I add page numbers to my navigation?