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.

Hi I have created a custom post type and custom taxonomy.The custom post type page is named page-portfolio.php.I have create a loop in it in witch I am trying to link to each posts single page.For that I have created a template single-portfolio.php but for some reason when I click the permalinks I get sent to the 404.php page.Here is my entire structure code:

//custom post type and taxonomy declaration
<?php

add_action('init' , 'portfolio_manager');

function portfolio_manager(){
    $args = array(
            'label' => 'Portfolio Manager',
            'singular_label' => 'Portfolio Manager',
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'supports' => array('title' , 'editor' , 'thumbnail'),
            'rewrite' => array(
                'slug' => 'portfolio',
                'with_front' =>false
            )
    );
    register_post_type('portfolio' , $args);
}

add_action('init' , 'portfolio_taxonomy');

function portfolio_taxonomy(){
    register_taxonomy("portfolio-type", 
                      array("portfolio"),
                      array("hierarchical" => true, 
                                "label" => "Portfolio Types",
                                "singular_label" => "Portfolip Type", 
                                "rewrite" => true, 
                                "slug" => 'portfolio-type'
                                )
                     );
}
?>
//page-portfolio.php loop
$portfolio = new WP_Query(array(
                        'post_type'=>'portfolio',
                        'posts_per_page'=>'-1'
                    ));
                    while($portfolio->have_posts()): $portfolio->the_post();
                     global $post;
                 ?>
                 <li class ="item" data-type="<?php echo str_replace(" " , "" , strip_tags(get_the_term_list($post->ID, 'portfolio-type' , '' , '' , ''))); ?>" data-id="id-<?php the_ID(); ?>">
                            <span><a href="<?php the_permalink(); ?>">Details</a></span>
                      <?php
                        endif
                      ?> 
                 </li>

                 <?php
                     endwhile;
                 ?>       

If single-portfolio.php is not the page template I should be creating for this page then what is the corect template?

If single-portfolio.php is the corect template then what am I doing wrong here.Why is the permalink not sending me to single.portfolio.php?

share|improve this question
    
This is basically the same question you asked 2 days ago. –  Chris_O Aug 20 '12 at 10:23

1 Answer 1

up vote 1 down vote accepted

When a new custom post type is created the re-write rules must flushed before the single permalinks will work.

Go to settings -> permalinks. Visiting the settings page will flush your re-write rules and your single post type permalinks will now work.

share|improve this answer
    
Thank you that did it –  Nistor Alexandru Aug 20 '12 at 10:32

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.