So, according to this page, it states:
single-{post_type}.php
If your custom post type were ‘product’, and/or query_var = “product”, WordPress would look for single-product.php to display the
single or permalink of the post.
So I have this code in my functions.php:
register_post_type( 'project',$args);
And I have this template: single-project.php
Then why isn’t my custom post using this template?
update
Using get_post_types()
I can see that my post type is not listed. If it is not registered, then why can I create and delete custom posts?
add_action('after_setup_theme','init_setup');
function init_setup() {
add_action( 'init', 'create_post_type' );
}
function create_post_type() {
$args = array(
'labels' => array(
'name' => __( 'Prosjekter' ),
'singular_name' => __( 'Prosjekt' ),
'add_new' => __('Nytt prosjekt')
),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'has_archive' => false,
'taxonomies' => array('category'),
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes','post_tag' ),
'rewrite' => array('slug' => 'prosjekt')
);
register_post_type( 'project',$args);
}
From the Codex:
Have you tried registering it like so?
[edit]
The only other thing I can think of is that since you’re using
rewrite
, you might want to flush the rewrite rules. Also from the Codex:If you don’t want to fiddle with the
flush_rewrite_rules()
function at this moment, just go into Settings > Permalinks and re-save your permalink preferences.