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

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(){
                      array("hierarchical" => true, 
                                "label" => "Portfolio Types",
                                "singular_label" => "Portfolip Type", 
                                "rewrite" => true, 
                                "slug" => 'portfolio-type'
//page-portfolio.php loop
$portfolio = new WP_Query(array(
                    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>


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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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