-
-
Save onuproy/61147ad67fe49de3f3924e6f0cb9bd6e to your computer and use it in GitHub Desktop.
Custom post type pagination
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
<?php | |
$custom_query_args = array ( | |
'post_type' => 'news', | |
'posts_per_page' => '4' | |
); | |
$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; | |
$custom_query = new WP_Query( $custom_query_args ); | |
$temp_query = $wp_query; | |
$wp_query = NULL; | |
$wp_query = $custom_query; ?> | |
<!-- loopity loop--> | |
<?php wp_reset_postdata(); ?> | |
<?php previous_posts_link( 'Older Posts' ); next_posts_link( 'Newer Posts', $custom_query->max_num_pages ); ?> | |
<?php // Reset main query object | |
$wp_query = NULL; | |
$wp_query = $temp_query; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment