Custom post type archive and single.php files not working

You have to flush your permalinks after you register these things. There are ways to do that automatically but the quick and dirty way is to browse to wp-admin->Settings->Permalinks and click “Save Changes”. That will work fine if this is your site and you aren’t distributing a plugin. If this is a plugin (which it probably should be), you can run flush_rewrite_rules(); on the plugin’s activation hook. An example of doing that from the Codex:

function myplugin_activate() {
    // register taxonomies/post types here
    flush_rewrite_rules();
}

register_activation_hook( __FILE__, 'myplugin_activate' );

function myplugin_deactivate() {
    flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'myplugin_deactivate' );

Other than that, I did not have any issue with your code (copied un-altered). The CPT registered and both single-shows.php and archive-shows.php worked after flushing the permalinks.

Leave a Comment