URL conflict between custom post type pagination and individual items
-
I have a custom post type set up, called “portfolio-photos”, that has a listing page (using query_posts) under the URL portfolio/photography (it’s a sub-page of portfolio). In my functions.php, I have the following line within the register_post_type function call:
'rewrite' => array('slug' => 'portfolio/photography'),
This is basically so that individual items have a URL like portfolio/photography/page-name – this is working. The list page at portfolio/photography is also working. However, the problem is that when I try to go beyond the first page, e.g. portfolio/photography/page/2, it just gives a 404.
It seems to be a conflict between the paging for portfolio/photography and the rewrite in functions.php that sets individual items up to have that URL. If I change one of them to a different name, both the paging and individual items work. Anybody know how I can fix this issue?
Note: the portfolio page, which indexes several custom post types (including photography), is working and is functioning with pagination. It seems to be child pages, which should index a single custom post type (e.g., artwork, photography) that struggle with the pagination.
Here is the code from the template I’m using for the list page, if it’s of any use:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts(array( 'post_type' => array('portfolio-photos'), // filter by post types 'posts_per_page' => 5, 'paged' => $paged // set the current page )); if (have_posts()): while ( have_posts() ) : the_post(); // loop through the posts - post template below this line ?> <div class="thumbnail"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_excerpt(); ?></a></div> <h3 class="worktitle"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>, created in <?php the_time('F Y'); ?></h3> <p class="tagged"><?php echo get_the_term_list( $post->ID, 'portfolio-tags', ' Tagged under ', ', ', '.' ); ?></p> <div class="hrmedium"></div> <?php endwhile; // end loop else: echo "<p>No posts found.</p>"; // message to show if nothing is found endif; if(function_exists('wp_paginate')) { wp_paginate(); } // add paging wp_reset_query(); // reset the query ?>
- The topic ‘URL conflict between custom post type pagination and individual items’ is closed to new replies.