Created
April 14, 2016 08:00
-
-
Save bepatrickdavid/df21915e7c41145941791f5bf88a0ee8 to your computer and use it in GitHub Desktop.
WP: Pagination custom post types
This file contains hidden or 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
<?php | |
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; | |
$the_query = new WP_Query( array ( | |
'post_type' => 'offer', | |
'post_status' => 'publish', | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'paged' => $paged | |
) ); | |
while ( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
//all what you need to show | |
<?php endwhile; ?> | |
<?php if(sizeof($the_query->posts) >= 9): ?> // based on settings of reading setting (number of post max show in blog) | |
<div class="nav-left"><?php next_posts_link(__('Older Entries','theme'), $the_query->max_num_pages) ?> | |
<div class="nav-right"><?php previous_posts_link(__('Newer Entries','theme')) ?></div> | |
<?php wp_reset_postdata(); ?> | |
<?php endif ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment