Created
October 29, 2017 00:11
-
-
Save larodiel/59a80203c7a2604c3062752fea015f12 to your computer and use it in GitHub Desktop.
WP Custom Query 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 | |
if(get_query_var('page')) { | |
$paged = get_query_var('page'); | |
} | |
elseif(get_query_var('paged')) { | |
$paged = get_query_var('paged'); | |
} | |
else { | |
$paged = 1; | |
} | |
// WP_Query arguments | |
$args = array( | |
'post_type' => array( 'my-post-type' ), | |
'post_status' => array( 'publish' ), | |
'nopaging' => false, | |
'paged' => $paged, | |
'posts_per_page' => 11, | |
); | |
// The Query | |
$media_query = new WP_Query( $args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment