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 tried many solutions to no avail and really need some help.

I have a Custom Post Type named "Portfolio" that is setup to display it's contents on a page called Portfolio.php. Wp PageNavi is hardcoded into the template and works fine under the Default permalink structure. When I try to switch permalinks to /%postname%/ and the URL becomes http://www.site.com/folder/portfolio/page/2/ it throws a 404.

Here is my code:

 <?php //query_posts('paged='.$paged);
   $temp = $wp_query;
   $wp_query= null;
   $wp_query = new WP_Query();
   $wp_query->query('showposts=10'.'&paged='.$paged);?>

 <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 6, 'paged' => $paged)); ?>
 <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

 <?php $custom = get_post_custom($post->ID);
       $screenshot_url = $custom["screenshot_url"][0];
       $website_url = $custom["website_url"][0];?>

    <div id="portfolio-item">
    <h1><?php the_title(); ?></h1>
    <a href="<?=$website_url?>"><?php if ( function_exists( 'get_the_image' )){get_the_image( array( 'custom_key' => array( 'post_thumbnail' ), 'default_size' => 'full', 'image_class' => 'alignright', 'width' => '280', 'height' => '187' ) ); }?> </a>
    <?php the_excerpt(); ?>
    </div>
    <?php endwhile; ?>
    </div>
    <div class="navigation">
    <?php include('includes/wp-pagenavi.php');
     if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    </div>

By everything I've read in the last few days I assume I need to either change the name of the page other than the name of the post type (which I don't think it would matter) or there is some rewrite rule I need to be adding. I've reset all the posts in the portfolio, and reset the permalinks many many times, Default always works but anything else breaks the following pages. What am I missing here?

share|improve this question

3 Answers 3

As far as i can its your query that is wrong... Chant

<?php //query_posts('paged='.$paged);
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=10'.'&paged='.$paged);?>

To

<?php 
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$paged = get_query_var('paged');
$wp_query->query('showposts=10'.'&paged='.$paged);?>
share|improve this answer
    
Thanks but it still only works for Default. Soon as I add /%postname%/ or any other permalink structure page 2 throws a 404. –  Emp FX Aug 18 '12 at 13:44
up vote 0 down vote accepted

Problem solved. It was because I had the Custom Post Type and the Page name the same, "Portfolio" for both. Once I changed this, I went to Settings > Permalinks and flushed. Re-Saved Links. Then checked all the posts links that was using the CPT, and everything went fine after that. I did use the edit from Breezer as well but it worked with or without the edit.

share|improve this answer

Your post type name and page name should not be same,

if your 'post_type' => 'portfolio' then create your page in different name using your WordPress admin.

Eg: Create your page name as "your site name portfolio"

Thank you and have a nice day..! :)

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.