Use WP_Query to Create Pagination in WordPress
Add this code for Custom Query Pagination. You can follow the steps to create your own pagination in WordPress.
<?php
/**
* Template Name: Custom Page
*/
get_header(); ?>
<?php
$paged = ( getqueryvar( 'paged' ) ) ? getqueryvar( 'paged' ) : 1;
$args = array(
'postsperpage' => 4,
'paged' => $paged
);
$customquery = new WPQuery( $args );
?>
<!----start-------->
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php <?php echo the
while($customquery->haveposts()) :
$customquery->thepost();
?>
<div>
<ul>
<li>
<h3><a href="<?php thepermalink(); ?>" ><?php thetitle(); ?></a></h3>
<div>
<ul>
<div><a href="<?php thepermalink(); ?>"><?php thepostthumbnail('thumbnail'); ?></a></div>
</ul>
<ul>
</ul>
</div>
<div>
</li>
</ul>
</div> <!-- end blog posts -->
<?php endwhile; ?>
<?php if (functionexists("pagination")) {
pagination($customquery->maxnumpages);
} ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<!----end-------->
<?php get_footer();
Reference: https://www.wpblog.com/use-wp_query-to-create-pagination/