admin管理员组文章数量:1130349
I am creating a theme and I have created a new Custom Post Type (CPT) called 'Custom Plugins'. I am trying to get this CPT to use its own template. I have created a single-custom-plugin.php - it doesn't use that. I have created single.php (still early stages with this theme I'm building it to help me learn more) - it doesn't use that either, it uses index.php again.
I'm not sure why this isn't working - I have been referring to the WordPress Developer site for help with structuring, in particular this link and the below image.
I would share the code for the pages, but I don't feel it is relevant as both single.php and single-custom-plugin.php have been temporarily setup as empty files with a single line comment stating the filename. Here is the code for my CPT (again, super basic - maybe I did something wrong here?):
function bravo_plugin_posttype() {
register_post_type('custom-plugins', array(
'labels' => array(
'name' => __('Custom Plugins'),
'singular' => __('Custom Plugin')
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => 'custom-plugins'
)
));
}
add_action('init', 'bravo_plugin_posttype');
I am creating a theme and I have created a new Custom Post Type (CPT) called 'Custom Plugins'. I am trying to get this CPT to use its own template. I have created a single-custom-plugin.php - it doesn't use that. I have created single.php (still early stages with this theme I'm building it to help me learn more) - it doesn't use that either, it uses index.php again.
I'm not sure why this isn't working - I have been referring to the WordPress Developer site for help with structuring, in particular this link and the below image.
I would share the code for the pages, but I don't feel it is relevant as both single.php and single-custom-plugin.php have been temporarily setup as empty files with a single line comment stating the filename. Here is the code for my CPT (again, super basic - maybe I did something wrong here?):
function bravo_plugin_posttype() {
register_post_type('custom-plugins', array(
'labels' => array(
'name' => __('Custom Plugins'),
'singular' => __('Custom Plugin')
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => 'custom-plugins'
)
));
}
add_action('init', 'bravo_plugin_posttype');
本文标签: template hierarchyCustom post type showing indexphp
版权声明:本文标题:template hierarchy - Custom post type showing index.php 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749041575a2307220.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论