Created
May 29, 2016 12:08
-
-
Save ozamancse/8c056e2f154c6a79de90b8b08c4762d6 to your computer and use it in GitHub Desktop.
Custom post loop with pagination
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 | |
| global $paged; | |
| $posts_per_page = 9; | |
| $settings = array( | |
| 'showposts' => $posts_per_page, | |
| 'post_type' => 'portfolio', | |
| 'orderby' => 'menu_order', | |
| 'order' => 'ASC', | |
| 'paged' => $paged) | |
| ); | |
| $total_found_posts = $post_query->found_posts; | |
| $total_page = ceil($total_found_posts / $posts_per_page); | |
| while($post_query->have_posts()) : $post_query->the_post(); | |
| // Your single post | |
| endwhile; | |
| if( function_exists('wp_pagenavi') ) { | |
| echo ' '.wp_pagenavi(array('query' => $post_query, 'echo' => false)).' '; | |
| } else { | |
| echo '<span class="nav-prev">'.previous_posts_link( 'Previous Posts' ).'</span> <span class="nav-next">'.next_posts_link( 'Next Posts' , $total_page ).'</span>'; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment