Skip to content

Instantly share code, notes, and snippets.

@iqbalrony
Last active July 24, 2019 10:06
Show Gist options
  • Select an option

  • Save iqbalrony/b5b4d351610ad002a6f38616639cc4a1 to your computer and use it in GitHub Desktop.

Select an option

Save iqbalrony/b5b4d351610ad002a6f38616639cc4a1 to your computer and use it in GitHub Desktop.
Custom pagination for custom post type.
$page_1 = isset($_GET['page_1'])? $_GET['page_1'] : 1;
$query_args = [
'post_type' => 'post',
'posts_per_page' => $settings['posts_per_page'],
'orderby' => $settings['orderby'],
'order' => $settings['order'],
'ignore_sticky_posts' => 1,
'post_status' => 'publish',
//'paged' => get_query_var('paged') ? absint(get_query_var('paged')) : 1,
'paged' => $page_1,
];
$big = 999999999; // need an unlikely integer
echo "<div class='page_numb'>";
echo get_pagenum_link($big);
echo paginate_links(array(
//'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
//'format' => '?paged=%#%',
'format' => '?page_1=%#%',
//'current' => max(1, get_query_var('paged')),
'current' => $page_1,
'prev_text' => '<i class="mdi mdi-chevron-left"></i>',
'next_text' => '<i class="mdi mdi-chevron-right"></i>',
'type' => 'list',
'total' => $the_query->max_num_pages,
'mid_size' => 1,
));
echo "</div>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment