Title: Pagination Issues
Last modified: August 21, 2016

---

# Pagination Issues

 *  [vladenstock](https://wordpress.org/support/users/vladenstock/)
 * (@vladenstock)
 * [12 years ago](https://wordpress.org/support/topic/pagination-issues-7/)
 * I am having troubles getting pagination to work with a page template. The goal
   of this code is to have a category news page that will place a featured article
   at the beginning of the news feed.
 * The way it must function is articles marked as the category AND marked as featured
   appear at the start of the page, the remainder of the posts just marked category
   appear below and should be paginated. This may be a result of calling 2 WP_Query’s,
   but am unsure as to how to accomplish this otherwise.
 * Here is what I have tried:
    - I have tried the WP-PageNavi with no success
    - I have tried using get_query_var(‘paged’); and get_query_var(‘page’);
    - I have tried wp_reset_postdata();
 * In an optimum world I would like it to display pagination as:
    Prev | 1 2 3 |
   Next
 * The page should display the number of articles set under wordpress >settings>
   general>reading (if that’s possible, otherwise it may be set in the template)
 * Articles should not be repeated, and the featured articles should only appear
   on the first page. I have removed the following code till I can get pagination
   working:
    `$do_not_duplicate = $post->ID;`
 * This wraps the featured articles loop
    `<?php if(!is_paged()): // Don't display
   featured content if you are within pagination as to not repeat posts ?>`
 * Please excuse the code I am new to both php and wordpress
 *     ```
       <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
   
       <div class="post">
   
       <?php
       	$args = array(
       		'category__and' => array(7,6),
       		'paged' => get_query_var('paged')
       	);
       	$posts_query = new WP_Query($args);
       ?>
   
       <?php if( $posts_query->have_posts() ) : while( $posts_query->have_posts() ) : $posts_query->the_post(); ?>
   
       	<?php get_template_part( 'content-post-featured', get_post_format() ); ?>
   
       	<?php endwhile; // end of the loop. ?>
   
       	<?php endif; ?>
   
       </div>
   
       <div class="post">
   
       <?php
       	$args = array(
       		'cat' => 7,
       		'category__not_in' => array(6),
       		'paged' => get_query_var('paged')
       	);
       	$posts_query = new WP_Query($args);
       ?>
   
       <?php if( $posts_query->have_posts() ) : while( $posts_query->have_posts() ) : $posts_query->the_post(); ?>
   
       	<?php get_template_part( 'content-post-standard', get_post_format() ); ?>
   
       	<?php endwhile; // end of the loop. ?>
   
       	<?php endif; ?>
   
       </div>
   
       <div id="postnavi">
       <?php posts_nav_link(); ?>
       </div>
       ```
   
 * It’s simply not returning pagination at all.. please help me.
 * Thanks!

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years ago](https://wordpress.org/support/topic/pagination-issues-7/#post-4874907)
 * ‘`posts_nav_link()`‘ only works with the default query;
 * you can try using `wp_pagenavi()` as desribed here [http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html](http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html)
 * or try using
    `next_posts_link( 'next', $posts_query->max_num_pages )`
 * [https://codex.wordpress.org/Function_Reference/next_posts_link](https://codex.wordpress.org/Function_Reference/next_posts_link)
   
   [https://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query](https://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query)

Viewing 1 replies (of 1 total)

The topic ‘Pagination Issues’ is closed to new replies.

## Tags

 * [pagination](https://wordpress.org/support/topic-tag/pagination/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/pagination-issues-7/#post-4874907)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
