Support » Themes and Templates » Pagination not working for custom post type

  • I keep getting page not found errors when trying to access the second page of posts.

    My code:

    global $query_string;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . "&post_type=Products&posts_per_page=3&paged=$paged");

    And to get the links:

    <div class="navigation">
    	<div class="alignleft"><?php next_posts_link('Next 3') ?></div>
    	<div class="alignright"><?php previous_posts_link('Previous
    3') ?></div>

    The Next 3 button shows up, but when clicked it returns a 404.

    My permalink setting is:

    I’ve tried changing the page settings in the admin console, and the “Category pagination fix” plugin with no success.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m using WordPress 3.2 with custom post types and having the exact same problem, using news-archive.php when going to the ‘next page’ (/news/page/2) I get error 404.

    I’ve looked over just about every post in these forums with the same issue but can’t seem to find a fix.

    My custom post type function:
    My news-archive.php file:
    My rewrite rules print:

    Would really appreciate anyones help here, I’ve been tearing my hair out over this all day!

    I was struggling with pagination for hours as well.. This is what I did that worked:

    <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
    <?php $offset = ( 5 * $paged ) - 5; ?>
    <?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'YOURPOSTTYPE', 'offset' => $offset); ?>
    <?php query_posts($args); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination not working for custom post type’ is closed to new replies.