How to display pagination for posts?
-
Hi,
I am using this code below to display a preview of my posts:
query_posts('cat=1&posts_per_page=1'); while ( have_posts() ) : the_post(); ?> <div class="span12 news-container left-align listnews"> <h3><?php the_title(); ?></h3> <p> <?php echo substr(get_the_content(), 0, 180); ?> <?php if (strlen(get_the_content()) > 180) { echo " ..."; } ?> </p> <a class="news-button" href="<?php the_permalink(); ?>">Read more...</a> </div> <?php endwhile; wp_reset_query();
I now need to display a pagination to this. I’ve been using a pagination for my custom post types which worked perfectly but the same one won’t work for normal posts. That’s the code:
$big = 999999999; echo '<div class="pagination">'; echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $loop->max_num_pages ) ); echo '</div>';
Is there something I could change on this to make it also work for my posts?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to display pagination for posts?’ is closed to new replies.