Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type portfolio and now I'm trying to enable navigation for the template where 10 portfolio items are shown. I'm using the following code to query the posts:

if ( get_query_var('paged') ) 
    { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) 
    { $paged = get_query_var('page'); }
else 
    { $paged = 1; }
$posts_per_page = get_option('posts_per_page');

$offset = ( $posts_per_page * $paged ) - $posts_per_page;

query_posts(array('paged'=>$paged, 'posts_per_page'=> $posts_per_page, 'post_type'=>'portfolio', 'offset' => $offset));

The current link structure is as follows:

domain.com/portfolio //main portfolio page, showing 10 portfolio items
domain.com/portfolio/item //shows a single portfolio item
domain.com/portfolio/page/2 //should show the next set portfolio items, but shows a 404 error instead.

I'm assuming the problem is that when you visit domain.com/portfolio/page/2 that WordPress assumes that page is a portfolio item, so it looks for that specific portfolio item rather than showing the next portfolio page.

How could I solve this issue? I'd rather not change the link structure for easier browsing.

I do not want to use a plugin like WP Page Navi, so this is not a duplicate with Pagination not working with custom loop

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The problem is that the page is named is the same as the custom post type, this is not possible in WordPress unfortunately.

You could solve this issue by changing the page its slug.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.