Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Making pagination works in custom page template in WordPress.
<?php
global $paged;
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array( 'post_type' => array('post'), 'paged' => $paged);
$wp_query = new WP_Query( $args );
if( $wp_query->have_posts() ):
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="post">
<?php the_title(); ?>
</div>
<?php
endwhile;
else:
?>
<p>No Posts Found</p>
<?php
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.