I was mistaken. The underscores are required by the template-files if they are part of the custom-post-type’s handle.
- Make sure to flush the rewrite cache / visit the permalinks page when working with cpt templates
- The archive.php template the missing cpt-template was falling back to looked similar
- Following
wp-includes/template-loader.php
>> get_post_type_archive_template >> get_archive_template doesn’t look like it’s rewriting underscores to hyphens
The characters used in the template filenames must match the cpt-handle exactly. WordPress coding standards require that filenames do not contain underscores.
We should (probably) avoid the use of underscores in cpt-handles.
Not sure if it’s WordPress or php/mysql version or settings related, but hyphens seem to be valid characters to use in post-type handles ( where I don’t recall them being previously )
eg: we couldn’t write
register_post_type( 'my-posttype' )
, but instead had to useregister_post_type( 'my_posttype' )
So we could register post-types with hyphens in the handles to
punctuate namespace from the actual handle & by doing so we would have cpt-archive/single page template filenames that are WordPress coding standards compliant