Forums

Custom Post Type pagination working only for child pages! (3 posts)

  1. gian-ava
    Member
    Posted 1 year ago #

    Hi,

    I am having this weird problem that will quiet surely make me go crazy.

    I got 2 Custom Post Types (Agenda and Quotes).
    The Agenda (Events) custom types are displayed from a template page "Agenda" with no parent.
    The Quotes types are child of "Extras".

    I got the same query structure and pagination (WP-Navi) only works for Quotes but not for Agenda (returns a 404 page).

    I experimented changing Agenda to a child page and pagination works.
    Than changed Quotes to assign no parent page, and get 404 when trying to paginate (quotes/page/2).

    Here is the code I use:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //for WP-PageNavi
    $quotesloop = new WP_Query(array(
    	'post_type' => 'quotes',
    	'posts_per_page' => 10,
    	'paged'=>$paged )
    	);
    
    while ( $quotesloop->have_posts() ) : $quotesloop->the_post();

    And than I use this:

    if(function_exists('wp_pagenavi')) { wp_pagenavi(array( 'query' => $quotesloop )); }

    I am now running WP 3.1 but i got the problem even before upgrading, on 3.0.5

    Any suggestion on the weirdness?
    Thanks…

  2. gian-ava
    Member
    Posted 1 year ago #

    Ok, this is not just about Custom Types. I discovered that normal posts got the same problem.

    If a page is an index of Posts or Custom Posts, the pagination works only if that page is a child of another page. When the page is not a child, pagination gets a 404 page.

    You can see it here:
    (Normal Posts - Doesn't work)
    http://manonuda.com/blog/
    http://manonuda.com/blog/page/2

    (Custom Posts - Doesn't work)
    http://manonuda.com/agenda/
    http://manonuda.com/agenda/page/2

    (Custom Posts - Works!)
    http://manonuda.com/extras/quotes/
    http://manonuda.com/extras/quotes/page/2

    Whenever I set the not working index pages as a child of another page, it works.

    I tried to deactivate all plugins, except WP-Pagenavi and qTranslate (because I got a function that breaks the page without the plugin installed), and didn't get anything as a result.

    Do you have any idea what's wrong?

  3. pusthebutton
    Member
    Posted 1 year ago #

    I think your problem may be coming from the page slug being the same as the name of your post type. Try changing the permalink of the page, this solved the problem for me.

Topic Closed

This topic has been closed to new replies.

About this Topic