I have a custom post type called podcast_episode
registered in functions.php
.
I also have a template ready called single-podcast_episode.php
When I create a new podcast_episode
post, the classic post editor has the Default
template selected. If I click the dropdown, I can see my single-podcast_episode
template.
How can I set it up so that the single-podcast_episode
template is the default for podcast_episode
posts?
I.e. How can I change the default template for a custom post type?
I would have thought according to the custom post type template files doc, the template hierarchy of my single-podcast_episode.php
would be enough, although maybe that only applies to the frontend?
Create custom post type code if needed:
function _s_create_custom_post_types() {
register_post_type(
'podcast_episode',
array(
'labels' => array(
'name' => __('Podcast Episodes'),
'singular_name' => __('Podcast Episode'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New Podcast Episode'),
'view_item' => __('View Item'),
'edit_item' => __('Edit Item'),
'search_items' => __('Search Items'),
'not_found' => __('Not Found'),
'not_found_in_trash' => __('Not Found in Trash')
),
'public' => true,
'hierarchical' => true,
'supports' => array('title', 'editor'),
'rewrite' => array(
'slug' => 'podcast/%taxonomy_name%',
),
'taxonomies' => array('podcast_episode'),
'query_var' => true,
'supports' => array('title', 'editor', 'thumbnail'),
)
);
}
add_action('init', '_s_create_custom_post_types');