I’m working on implementing WordPress coding standards on a theme which has several custom post-types, each of which have underscores in their handles.
The theme uses the custom post-type handle in the file-names, eg: archive-my_posttype.php
for the my_posttype
post-type… But WordPress coding standards require that filenames use hyphens and not underscores, ( see WordPress.Files.FileName.NotHyphenatedLowercase
for more info )
I’ve changed the file-name of the archive-template to archive-my-posttype.php
but I’m apprehensive because I remember this behavior didn’t exist previously.
example:
register_post_type( 'my_posttype' /* truncated for brevity */ );
Would correspond to the template-files archive-my_posttype.php
& single-my_posttype.php
but not archive-my-posttype.php
& single-my-posttype.php
I recall being required to use the underscores in my filenames in the past. Can anyone tell me when this was changed and if it has anything to do with the rewrite-attribute being set when the CPT is registered?
I’m happy to see that I can replace the underscores with hyphens without issue, I’m just wondering when this became not an issue & if anyone knows any other conditions of this feature that people should be aware of