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 );
}