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.

WP Hierarchy

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');
  • First of all... Your CPT is custom-plugins, so the template should be single-custom-plugins.php (with s at the end). But single.php should work just fine. Where do you add these files? – Krzysiek Dróżdż Jan 5 '19 at 13:48
  • "it uses index.php again" - what URL are you calling? – kero Jan 5 '19 at 13:55
  • 1
    Thanks - it is actually saved as single-custom-plugins.php, I edited it as I thought I'd copied it over wrong. I renamed the CPT since testing last and was reloading the page /plugins/{custom-plugin-name} - which explains why it wasn't working. Thanks for the help, all seems to be working as expected now. – D. Winning Jan 5 '19 at 14:08
  • @D.Winning Happy to hear you got it working. Feel free to either self-answer this or delete the question – kero Jan 5 '19 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.