• Resolved falkencreative

    (@falkencreative)


    Try #2 – My last post says it has been closed?

    Hello all,

    I have a site I am working on that uses custom post types extensively. I have been able to get pagination on custom post types working correctly. Unfortunately, when I go to a category page and try to go to page 2 I get a 404 error.

    Any guesses?

    Here’s the site (still under development): ht tp://thermosp okenhere.com/wp/ [remove spaces]
    Here is a working category page: ht tp://thermospoke nhere.com/wp/category/a/
    And a non-working category page: h ttp://thermosp okenhere.com/wp/category/a/page/2

    I’m using month/name permalink settings: htt p://thermospokenh ere.com/wp/2010/10/sample-post/

    Here is the code that lists the posts on the categories page:

    $catid = get_query_var('cat');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=$catid&post_type=narrative&posts_per_page=2&paged=$paged&orderby=menu_order&order=ASC");        
    
    while (have_posts()):the_post(); ?>

    And here is the code that creates the custom post type:

    register_post_type( 'narrative',
            array(
                'labels' => array(
                    'name' => __( 'Narratives' ),
                    'singular_name' => __( 'Narrative' ),
                    'add_new' => __( 'Add New' ),
                    'add_new_item' => __( 'Add New Narrative' ),
                    'edit' => __( 'Edit' ),
                    'edit_item' => __( 'Edit Narrative' ),
                    'new_item' => __( 'New Narrative' ),
                    'view' => __( 'View Narrative' ),
                    'view_item' => __( 'View Narrative' ),
                    'search_items' => __( 'Search Narratives' ),
                    'not_found' => __( 'No Narratives found' ),
                    'not_found_in_trash' => __( 'No Narratives found in Trash' ),
                    'parent' => __( 'Parent Narrative' ),
                ),
                'public' => true,
                'show_ui' => true,
                'publicly_queryable' => true,
                'exclude_from_search' => false,
                //'hierarchical' => true,
                'query_var' => true,
                'supports' => array( 'title', 'comments' ),
                'rewrite' => array( 'slug' => 'content'),
                'taxonomies' => array( 'category')
            )
        );

    I have tried http://wordpress.org/extend/plugins/custom-post-type-category-pagination-fix/ but it doesn’t seem to do anything for me.

Viewing 1 replies (of 1 total)
  • Thread Starter falkencreative

    (@falkencreative)

    Nevermind, got things sorted. The source of the issue is that my “Blog pages show at most” setting under Settings > Reading was set to 8, whereas the query_posts() function was set to use 2. For some reason or another, using the two different values caused the issue.

    Removing the posts_per_page variable from the query_posts() function or setting both to use the same number fixes things.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Types, Categories and Pagination’ is closed to new replies.