Last active
November 7, 2022 10:22
-
-
Save MrJoshFisher/7f1c3cca66d230c62973f8c43e1fa76f to your computer and use it in GitHub Desktop.
[WordpressPagination]
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
$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