Adding pagination to custom post query
-
Hello,
I have a page that displays posts from a specified category.
I have 10 posts showing but I would like there to be pagination for the option to view previous posts.
The code I am using to generate the posts is:
<section class="front-page archives clear"> <section class="archive"> <?php $query = new WP_Query( array( 'post_type' => 'post', 'category_name' => 'press', 'posts_per_page' => 8, 'order' => desc ) ); ?> <?php while ($query->have_posts()) : $query->the_post(); ?> <?php if (empty($post->post_excerpt)) { ?> <div class="news"> <div class="newsImgPage"> <?php the_post_thumbnail();?> </div> <div class="newsTextPage"> <h2><?php the_title(); ?></h2> <span class="nDate"><?php the_date( 'F j Y' ); ?></span> <p><?php the_content(); ?></p> </div> </div> <?php } else { ?> <div class="news"> <div class="newsImgPage"> <?php the_post_thumbnail();?> </div> <div class="newsTextPage"> <h2> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h2> <span class="nDate"><?php the_date( 'F j Y' ); ?></span> <p><?php the_excerpt(); ?></p> </div> </div> <?php } endwhile; ?> </section> </section>
Any help much appreciated
Thanks
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding pagination to custom post query’ is closed to new replies.