Dec
01
2011Resolve Pagination Problem for Custom Post Types Listing in WordPress
Tags: Custom Post Type
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:
- Include & Display Custom Post Type Records under Categories Posts Listing in WordPress
- WordPress Custom Post Type Listing by Alphabets with Alphabetical Navigation
- WordPress Custom Post Types – Best Plugin for the Job and How to Set it Up
- Resolve Permalinks 404 Error with Custom Post Type using WordPress
- Resolve AdSense Google Custom Search Engine Blank Results Page on Your Website
Recent Comments
(9 hours ago)
(9 hours ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)
(1 days ago)