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 set up a custom post titled project where I have also set a theme file page-project.php. When I create a post under that custom post type, and I preview it, it shows on the using the page-project.php template, however once I publish it and view the page, it uses the index.php template. Can someone tell me why this is happening?

This is my custom post type from functions.php

FYI: just found this out, if I turn permalinks to default settings, it uses the correct template as well.

add_action('init', 'project_register'); 
function project_register() {
    $labels = array(
        'name' => _x('My Projects', 'post type general name'),
        'singular_name' => _x('Project', 'post type singular name'),
        'add_new' => _x('Add New', 'project item'),
        'add_new_item' => __('Add New Project Item'),
        'edit_item' => __('Edit Project Item'),
        'new_item' => __('New Project Item'),
        'view_item' => __('View Project Item'),
        'search_items' => __('Search Project'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
        'rewrite' => true,
        'capability_type' => 'page',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail','author')
      );

    $labels = array(
    'name' => _x( 'Project Types', 'taxonomy general name' ),
    'singular_name' => _x( 'Project Type', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Project Types' ),
    'all_items' => __( 'All Project Types' ),
    'parent_item' => __( 'Parent Project Type' ),
    'parent_item_colon' => __( 'Parent Project Type:' ),
    'edit_item' => __( 'Edit Project Type' ), 
    'update_item' => __( 'Update Project Type' ),
    'add_new_item' => __( 'Add New Project Type' ),
    'new_item_name' => __( 'New Project Type Name' ),
    'menu_name' => __( 'Project Type' ),
  ); 
    register_taxonomy('project_type',array('project'), array('hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'type' ),));
    register_post_type( 'project' , $args );
}
share|improve this question
add comment

1 Answer 1

Custom Posts don't use custom static page template files. Custom Posts have their own template files for custom post archive index pages and single custom post pages.

For a single custom post page, you need to create a single-{post-type}.php, which for you would be single-project.php.

Similarly, for a custom post archive index page, you need to create a archive-{post-type}.php, which for you would be archive-project.php.

share|improve this answer
    
Assuming you overlooked my post, I set us this already, but my custom post type has capability_type set to page, it works outside of SEO friendly permalink urls. however I would like to use the SEO friendly permalink urls –  BrettAdamsGA May 25 '12 at 15:06
1  
The capability_type parameter doesn't mean what you seem to think it means. :) That simply tells WordPress which user capabilities to apply to this post type. That is: a user who can edit/publish/delete pages will be able to edit/publish/delete projects as well. Also: custom post types fully support pretty-permalink rewrite rules. All your SEO-friendliness is built right in. –  Chip Bennett May 25 '12 at 15:14
add comment

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.