Resolve Pagination Problem for Custom Post Types Listing in WordPress

Tags:
wordpress-plugin

In WordPress, Custom Post Type is great feature to manage your custom content such as portfolio which can’t be managed properly with the default posts or pages type.

One of the problem in working with custom post types is the pagination issue. If you are viewing the same records on the next or third page of listing, you need to catch $paged variable and pass to the query like this:

 
<?php
  wp_reset_query();
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 
$args = array( 'post_type' => 'portfolio', 'posts_per_page' => 10, 'paged'=>$paged, 'orderby' => 'order', 'order' => 'ASC' );
 
 query_posts($args); 
 
    if (have_posts()) : while (have_posts()) : the_post(); 
 
?>
 
//your html code here
 
 
<?php endwhile; else: ?>
 
	<p>Sorry, no record matched your criteria.</p>
 
 <?php endif; ?>

Hope that helps.

Cheers!

Related posts:

  1. Include & Display Custom Post Type Records under Categories Posts Listing in WordPress
  2. WordPress Custom Post Type Listing by Alphabets with Alphabetical Navigation
  3. WordPress Custom Post Types – Best Plugin for the Job and How to Set it Up
  4. Resolve Permalinks 404 Error with Custom Post Type using WordPress
  5. Resolve AdSense Google Custom Search Engine Blank Results Page on Your Website