Last active
August 29, 2015 14:07
-
-
Save joeyz/ad53f779f63678e1ccc4 to your computer and use it in GitHub Desktop.
Wordpress Pagination for archive page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Dont forget to set how many items you want on each page in "Settings > Reading > Blog pages show at most" | |
<?php | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
// WP_Query arguments | |
$args = array ( | |
'pagination' => true, | |
'paged' => $paged, | |
'order' => 'ASC' | |
); | |
// The Query | |
$query_events = new WP_Query( $args ); | |
// The Loop | |
if ( $query_events->have_posts() ) { | |
while ( $query_events->have_posts() ) { | |
$query_events->the_post(); | |
?> | |
//Do some stuff in the loop | |
<?php | |
} | |
} else { | |
echo 'Nothing going on here boss'; | |
} ?> | |
<div class="nav-previous alignleft"><?php next_posts_link( 'Later Events' ); ?></div> | |
<div class="nav-next alignright"><?php previous_posts_link( 'Closer Events' ); ?></div> | |
<?php // Restore original Post Data | |
wp_reset_postdata(); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment