Title: custom post pagination
Last modified: August 21, 2016

---

# custom post pagination

 *  Resolved [Jerry1234](https://wordpress.org/support/users/jerry1234/)
 * (@jerry1234)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-post-pagination/)
 * I have the following code when however the next posts and the previuos posts 
   links doesn’t show on the page.
 *     ```
       <?php
       		$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
       		$product_posts = new WP_Query(
       			array (
       				'post_status' => 'publish',
       				'post_type' => 'product',
       				'post_per_page' => 2,
       				'paged' => $paged
       			)
       		);
   
       		if( $product_posts->have_posts() ) : while( $product_posts->have_posts() ) : $product_posts->the_post(); ?>
       			<div id="products">
       				<div class="center">
       					<div class="product-title">
       						<?php the_title(); ?>
       					</div> <!-- product-title -->
       					<div class="product-image">
       					<?php
       						if( has_post_thumbnail() ) {
       							set_post_thumbnail_size( 200 );
       							the_post_thumbnail();
       						}
       					?>
       					</div><!-- product-image -->
       					<div class="price">
       						<b>Price: </b><?php echo get_post_meta( get_the_ID(), 'price_text', true ); ?>
       					</div><!-- price -->
       					<div class="float-right">
       						<?php
       							$stock_meta = get_post_meta( get_the_ID(), 'stock_text', true );
       							if( $stock_meta > 0 ) {
       								echo '<span class="in-stock">In stock</span>';
       							}
       							if( $stock_meta <= 0 ) {
       								echo '<span class="out-of-stock">Out of stock</span>';
       							}
       						?>
       					</div><!-- float-right -->
       				</div><!-- center -->
       			</div> <!-- products -->
       		<?php endwhile; endif; ?>
       		<div class="clear-both"></div><!-- clear-both -->
         <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
         <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-post-pagination/#post-3915320)
 * See:
    [http://codex.wordpress.org/Pagination#Troubleshooting_Broken_Pagination](http://codex.wordpress.org/Pagination#Troubleshooting_Broken_Pagination)
   Try adding the ‘max_num_pages’ property to the next_posts_link() function. [http://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query](http://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query)
 *  Thread Starter [Jerry1234](https://wordpress.org/support/users/jerry1234/)
 * (@jerry1234)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-post-pagination/#post-3915366)
 * Well that was simple thank you so much! I really appreciate it 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘custom post pagination’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Jerry1234](https://wordpress.org/support/users/jerry1234/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/custom-post-pagination/#post-3915366)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
