WordPress.org

Ready to get started?Download WordPress

Forums

Does Paging work on Custom Post Type Archives? (10 posts)

  1. driz
    Member
    Posted 3 years ago #

    I have a custom post type called Questions on my website and I'm using the new 3.1 feature to have an index page to show all the posts which is at this url: domain.com/qna/

    However the paging doesn't seem to work. When I go to domain.com/qna/page/2/ I just get a 404. Is this a bug with 3.1 or does paging not work with archives?

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 3 years ago #

    I have tested all my CPT's using new archive feature on 3.1

    Some have custom queries, some do not. All paginate properly

    Flush your permalinks by visiting your settings->permalinks page and hitting save

    (I believe just visiting the page does it, but hitting save doesn't hurt)

    See if that helps

  3. driz
    Member
    Posted 3 years ago #

    Tried that several times and still not getting anywhere :/

    I have even tried adding the following in the template archive-questions.php to see if I can force the paging:
    <?php global $query_string; query_posts( $query_string . 'orderby=date&posts_per_page=10&post_type=questions&paged=' . get_query_var( 'page' ) ); ?>

    But still I get a 404 :/

  4. keesiemeijer
    moderator
    Posted 3 years ago #

    Try it with this:

    <?php
        if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
        elseif ( get_query_var('page') ) { $paged = get_query_var('page');
        } else { $paged = 1; }
    ?>
    <?php global $query_string; query_posts( $query_string . 'orderby=date&posts_per_page=10&post_type=questions&paged=' . $paged); ?>
  5. driz
    Member
    Posted 3 years ago #

    Still get the 404 :( tried flushing the permalinks again after adding your code but still get a 404!

    Here is archive-questions.php in full: http://pastebin.com/6ZPLz975

    Do you see any problems? Thanks.

  6. keesiemeijer
    moderator
    Posted 3 years ago #

    Can we see how you registered your post type (register_post_type) in functions.php.
    if you have something like this in it:
    'rewrite' => array( 'slug' => 'questions', 'with_front' => true ),
    try and change it to:
    'rewrite' => array( 'slug' => 'question', 'with_front' => true ),
    and see if that helps

    Try quering without the query string:

    <?php
        if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
        elseif ( get_query_var('page') ) { $paged = get_query_var('page');
        } else { $paged = 1; }
    ?>
    <?php query_posts('orderby=date&posts_per_page=10&post_type=questions&paged=' . $paged); ?>
  7. driz
    Member
    Posted 3 years ago #

    Here: http://pastebin.com/WZyGcju6

    I've tried it with and without the query_posts but the pagination still does not work

  8. driz
    Member
    Posted 3 years ago #

    any updates? thanks

  9. onepack
    Member
    Posted 3 years ago #

    Same here... No luck whatever I do.

  10. onepack
    Member
    Posted 3 years ago #

    It seems like a bug to me because I and many others cannot get this to work on a custom post type archive.

Topic Closed

This topic has been closed to new replies.

About this Topic