Skip to content

Instantly share code, notes, and snippets.

@MrJoshFisher
Last active November 7, 2022 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrJoshFisher/7f1c3cca66d230c62973f8c43e1fa76f to your computer and use it in GitHub Desktop.
Save MrJoshFisher/7f1c3cca66d230c62973f8c43e1fa76f to your computer and use it in GitHub Desktop.
[WordpressPagination]
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'order' => 'desc',
'orderby' => 'date',
'paged' => (get_query_var('paged') ? get_query_var('paged') : 1)
);
$post_query = new WP_Query($args);
if($post_query->have_posts() ) {
while($post_query->have_posts() ) {
$post_query->the_post();
?>
<h2><?php the_title(); ?></h2>
<?php
}
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $post_query->max_num_pages,
'prev_text' => '<',
'next_text' => '>'
) );
}
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment