<?php // set up or arguments for our custom query $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $query_args = array( 'post_type' => 'post', 'category_name' => 'tutorials', 'posts_per_page' => 5, 'paged' => $paged ); // create a new instance of WP_Query $the_query = new WP_Query( $query_args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?> <article> <h1><?php echo the_title(); ?></h1> <div class="excerpt"> <?php the_excerpt(); ?> </div> </article> <?php endwhile; ?> <?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?> <nav class="prev-next-posts"> <div class="prev-posts-link"> <?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?> </div> <div class="next-posts-link"> <?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?> </div> </nav> <?php } ?> <?php else: ?> <article> <h1>Sorry...</h1> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> </article> <?php endif; ?>