WP Query Pagination
-
Hi,
I’m trying to add pagination to a wp_query loop but I can’t get it to work, if anyone can help it’ll be much appreciated! Here’s my code:
<?php $args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 2, ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <h3 class="category"><?php the_category(', ') ?></h3> <div class="blogContainer"> <div class="blogpiece"> <div class="titleMeta"><div class="metaDeets">by <?php the_author(); ?> | <?php the_time('g:i') ?> | <?php the_time('d/m/Y') ?></div><h6><?php the_title(); ?></h6></div> <div class="mainText"> <?php the_excerpt(); ?> </div> <div class="readMorebox"><a href="<?php echo get_permalink(); ?>">? Read more</a></div> </div> </div> <?php endwhile; ?> <?php posts_nav_link(' — ', __('? Newer Posts'), __('Older Posts ?')); ?> <?php } wp_reset_query(); ?>
- The topic ‘WP Query Pagination’ is closed to new replies.