I created a custom post, and made a template file named single-postname.php
I can’t get the template file to load, before I would just get re-directed back to the homepage, but after flushing the .htaccess file I just get a blank page.
I tried removing and adding the post again, changed the permalinks a couple times, and changed the theme, nothing seems to work. Is there anything else I can do to try forcing WordPress to look for the file again?
The register_post_type
$labels = array(
'name' => _x( 'Conversations', 'conversation' ),
'singular_name' => _x( 'Conversation', 'conversation' ),
'add_new' => _x( 'Add New', 'conversation' ),
'add_new_item' => _x( 'Add New Conversation', 'conversation' ),
'edit_item' => _x( 'Edit Conversation', 'conversation' ),
'new_item' => _x( 'New Conversation', 'conversation' ),
'view_item' => _x( 'View Conversation', 'conversation' ),
'search_items' => _x( 'Search Conversations', 'conversation' ),
'not_found' => _x( 'No conversations found', 'conversation' ),
'not_found_in_trash' => _x( 'No conversations found in Trash', 'conversation' ),
'parent_item_colon' => _x( 'Parent Conversation:', 'conversation' ),
'menu_name' => _x( 'Conversations', 'conversation' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'conversation between users on the site',
'supports' => array( 'title', 'excerpt', 'author', 'comments', 'custom-fields' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
//'menu_icon' => 'http://findicons.com/files/icons/2229/social_media_mini/24/google_talk.png',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'conversation', $args );
Filename = single-conversation.php
According to the template hierarchy, if you’re looking to output an archive of all posts under custom post type “xyz” then you would create a file called “archive-xyz.php” and put it in your page-templates directory. If you’re looking to output a single post under the custom post type “xyz” then WordPress will look for a file called “single-xyz.php.”
http://codex.wordpress.org/Template_Hierarchy
There’s my attempt at elucidation 🙂