Hyphens instead of Underscores in Post-type Archive Template Filenames when Post-type handle contains underscore

I was mistaken. The underscores are required by the template-files if they are part of the custom-post-type’s handle.

  1. Make sure to flush the rewrite cache / visit the permalinks page when working with cpt templates
  2. The archive.php template the missing cpt-template was falling back to looked similar
  3. 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 use register_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