Skip to content

Instantly share code, notes, and snippets.

@tubiz
Created August 18, 2013 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubiz/6263287 to your computer and use it in GitHub Desktop.
Save tubiz/6263287 to your computer and use it in GitHub Desktop.
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