Skip to content

Instantly share code, notes, and snippets.

@larodiel
Created October 29, 2017 00:11
Show Gist options
  • Save larodiel/59a80203c7a2604c3062752fea015f12 to your computer and use it in GitHub Desktop.
Save larodiel/59a80203c7a2604c3062752fea015f12 to your computer and use it in GitHub Desktop.
WP Custom Query Pagination
<?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