Should custom directories be created under the wp-content directory?

If there is a need for custom files e.g. CSS that need to be called, should a custom directory e.g. css be created under wp-content e.g. wp-content/css?

No, never. You should not do this under any circumstances.

A themes assets belong in the theme. A plugins assets belong in that plugin. The only exception is when a child theme uses assets in its parent theme. Doing otherwise would be considered negligent by most WordPress developers, and a major red flag to many employers.

A themes folder should contain everything. It should not reference or store assets in a custom folder under wp-content.

This goes for anything your theme needs that isn’t included with WP core or a parent theme. JS, CSS, JSON, PNG, PHP, etc etc. You can require the use of a plugin for functionality, or use a parent theme, but don’t place parts of your theme in subfolders outside the theme folder. Likewise with plugins.

What Are The Consequences?

Here is a partial list of consequences, though many more exist:

  • Your theme would immediately fail wp.org review, as well as the review of theme market places
  • Automated tooling for testing and checking would no longer function correctly
  • The theme upload page would no longer fully install your theme as it doesn’t know about your custom folder
  • Theme updates would no longer fully update your theme
  • Multiple themes that do this would cause conflicts, particularly on Multisite installations
  • Caching and optimisation plugins may break the assets you placed in the custom folder, or fail to pick them up
    • poorly built caching plugins may even use a css subfolder and overwite your work. A well built plugin would instead use the uploads folder ( you should not use the uploads folder for theme assets, this has security and practical consequences )
  • your theme will break on some enterprise grade and managed hosting due to folder mapping tech that doesn’t account for the custom folder
  • certain CI deployment processes would need manual modification to account for the folders or they’ll be stripped out on deployment
  • Unexpected folders in wp-content imply that the site has been compromised
  • Incompatibility with composer
  • Incompatibility with WP CLI

What About Subfolders Inside My Themes Folder?

Inside your theme you can organise assets however you want, it’s up to you. Put them in the root, put them in subfolders, it’s your choice and there is no required location for theme sub-folder structure.

The only CSS file that needs a specific location is style.css which must be in the root as WordPress looks for it to read the theme name etc. Likewise top level PHP templates and functions.php go in the root folder.


When Might Custom Folders in wp-content Make Sense?

They never make sense for theme developers.

The only time I’ve seen custom non-standard folders used in the wp-content folder are as follows:

  • vendor folders created by the composer tool for PHP dependencies
  • subfolders for CI such as .gitlab, or .github if your site is in version control, that aren’t used by WP or the site, but are a part of the development process
  • folders required by hosting platforms, usually a sign of an unusual architecture at an enterprise level. A common example is when a hosting provider uses plugins-mu and provides a second folder for client mu plugins ( also a sign that it never occurred to them to load that code with a drop in file and let the client use plugins-mu )

You may find some caching plugins use a cache subfolder, but there’s no reason this can’t be moved under uploads/.

In general, good reasons to make new subfolders in wp-content are 1 in a billion, and almost always a sign that something has gone wrong in the development process. Those edge cases that are allowable have nothing to do with the running site or are part of unusual high end hosting setups

Then Why Does The Article Recommend wp-content/css?

It doesn’t.

In contrast another article recommends creating a sub-directory in the root directory e.g. public_html/subdirectory

This article does not recommend this. You are mistaken. It recommends a subdirectory of the themes folder, not wp-content. E.g. wp-content/themes/yourtheme/css

The TLDR

  • Put your themes assets inside your theme
  • Put your plugins assets inside your plugin
  • Unless you absolutely require it and it is unavoidable, don’t create non-standard folders in wp-content
    • It’s very likely that you don’t require it, consult with other WP devs, these situations are extremely rare
    • If you need it for a theme, something has gone horribly wrong