Wordpress - Dash or underscore in theme folder name?
In short, there is no well defined convention for naming a theme's directory, and all of the following are valid (among others):
my_wordpress_theme
my-wordpress-theme
(empirically the most popular option within the ecosystem)MyWordPressTheme
mywordpresstheme
(what the default themes use)
Details
The WordPress PHP Coding Standards Handbook states that filenames should be all lowercase and hyphen-separated. As Squish points out, various routines in the WordPress Template Hierarchy rely on this convention in order to auto-load templates for certain situations.
All of that said, you will not break Linux or Apache by using underscores instead of hyphens (though you will break conventionally loaded files in the template hierarchy). Directories don't seem to have any well-defined conventions, but as a rule of thumb avoid spaces in all of your names. Dots may or may not have undesired effects in directory names, particularly as *NIX conventions traditionally handle directories beginning with a dot as "hidden."
As the WP_Theme class's scandir()
function makes direct use of PHP's scandir()
followed by is_dir()
in order to enumerate the individual themes in a directory rather than testing the naming conventions of entries, it shouldn't actually matter what your directories are named as WordPress itself largely ignores the directory name for this purpose. You can read the comments on the is_dir()
page for some specific caveats. More than anything, ensure that your directory names work in URL-format and are navigable by a web-browser.
The themes packaged with WordPress use a directory naming convention of all lowercase letters and no punctuation, i.e. twentytwelve
, twentythirteen
, etc.
For directories it's personal preference (you can use spaces, too... not really recommended, though).
Wordpress convention seems to be dashes, though.
Especially because Wordpress does use dashes for special files.
For instance when you are making page templates, you can make a file called "page-special" and the template will load automatically for the page name "special". (e.g website.com/special)