WordPress at Your Fingertips

wp-content Directory

WordPress consists of 3 folders wp-includes, wp-admin, wp-content and several files next to these folders.

All files and folders except wp-content - this is WordPress, the engine. That is, the directories: wp-includes and wp-admin are the core of WordPress, and wp-content is everything else - all user data...

The wp-content directory is where almost all user files are stored, except for the wp-config.php configuration file (which is an integral part of the core). This is where plugins, themes, plugin files, themes and site content are stored. This is also the place to store all the files associated with the expansion of WordPress.

Initially in WordPress, wp-content contains one file index.php and 3 folders: plugins, themes, languages.

File wp-content/index.php

Should always exist and should have this content:

<?php // Silence is golden.

This file prevents you from seeing a list of files in the folder. If index.php doesn't exist and your web server allows you to see files in directories, then clicking on the link http://example.com/wp-content you can see all the files and folders in that directory. This can be used by hackers to gain access to key files, allowing the site to be compromised. For example, if you have a vulnerable plugin installed, the site could easily be checked for that vulnerable plugin, and then the attacker could easily break the site.

When updating WordPress manually, never touch the wp-content folder or anything in it. It has nothing to do with updating WordPress.

A list of what what the wp-content directory may contain:

/mu-plugins - must-use plugins

In WordPress there are "Mandatory plugins", they they are located in the wp-content/mu-plugins directory. About them I wrote in separate article, be sure to check it out!

Briefly about Must-use plugins: Must-use plugins, also known as mu-plugins are plugins that are installed in a special mu-plugins folder in the content wp-content directory
and activated automatically (always active) for the site and network sites. These plugins are not visible among the regular plugins. In the admin panel, they appear in the top info line and there is no way to disable them except to delete the plugin file from the wp-content/mu-plugins directory.

/plugins - plugins

WordPress plugins are located in the wp-content/plugins directory. A plugin can be a single file or multiple files within a folder. Any files in the /plugins directory are scanned by WordPress to determine if the file is a plugin file. If the file is determined to be a plugin, it appears in the admin panel under "Plugins" and is ready to be activated.

To deactivate a plugin, you can delete the plugin from the /plugins folder. You can also rename the name of the folder, in which case, WordPress simply can not find the plugin file and will deactivate it while trying to connect. But keep in mind that it is better to delete plugins from the admin panel, through the Delete button, because the deletion triggers some functions that clean up the plugin data in the database or in the files.


WP Themes are stored in the wp-content/themes directory. Each theme must be in its own folder and contain a properly formatted style.css file so that WordPress will recognize it as a usable theme. There should be at least 2 files in the theme directory: index.php and style.css.

WordPress can store as many themes as you want in this directory. You can easily view any available theme or activate it in the Appearance ► Themes tab in the admin panel.

/uploads - media and other files

WordPress stores uploaded files in the wp-content/uploads directory. This directory does not exist in the WordPress distribution by default. It is created when the file is first uploaded to WordPress. A separate creation is necessary because this folder can be moved to another location (see below)

By default, WordPress stores uploads in folders by year and month:


Before any images or files can be uploaded to WordPress, the server must be allowed to create folders in the /wp-content directory. When the first image is uploaded, WordPress automatically creates the /uploads directory and the necessary sub-directories in it. After the first file is uploaded, you need set the permissions for /wp-content back, usually 755. Some servers allow the php script to create folders and files right away.

The uploads directory should have all permissions to allow PHP freely create and delete files in it, usually it's 777 permissions.

WordPress does NOT know how to recognize and import images to admin uploaded to uploads directly (not through the admin). And such files don't show up in the WordPress file library - WordPress doesn't know anything about them.

uploads to Multisite

In Multisite installation for the main site files are uploaded as usual. And for all additional sites, creates a folder /wp-content/uploads/sites/2, where 2 is the network site ID.

So for each site is created a folder with its ID in the /wp-content/uploads/sites directory. Then the files are also arranged in folders by year and month.

This approach allows to separate uploads for each site and simplifies their maintenance.

Before WP 3.5, the files of additional sites were not located in /wp-content/uploads/sites, but in /wp-content/blogs.dir.

So, for example, the directory for a site with ID 3 looks like this:

  • WP 3.5 and above: /wp-content/uploads/sites/3.
  • WP 3.4 and below: /wp-content/blogs.dir/3
Moving the uploads folder

To move the uploads folder, you need to define the UPLOADS constant in wp-config.php as follows:

// this means that the uploads folder should be in the root of the site
define( 'UPLOADS', 'uploads' );

Or you can change the options: upload_path and upload_url_path in the options table, see update_option().

Moving the uploads folder is not recommended, I wrote about it in the article: Bug with moving the uploads folder.


/upgrade - auto updates

The wp-content/upgrade directory is created automatically by WordPress when you update WordPress. This folder is used to store the new version of WordPress downloaded from WordPress.org. Before updating, WordPress downloads the archive and extracts its contents into this folder. For the automatic update process to be successful, it is recommended not to touch this folder. If this directory is deleted, WordPress will create it the next update.

/languages - translations

wp-content/languages directory is present only if you install a non-English version of WordPress. This contains all the localization (translation) files of WordPress. Such files have extensions:

  • .mo - a compressed version of a similar .po file, which is used by PHP for translation.
  • .po - the original translation file. This file can be used to edit the translation. After editing it must be compiled into a compressed version with the .mo extension.

There may also be special sub-directories in languages dir:

  • /pliugns - contains translations of plugins. Plugin translation file must have the format: plugin_name-local.mo, for example: akismet-ru_RU.mo. Before loading its translation file, the plugin checks if there is a translation file in this folder, and if it is there, then this translation file is used instead of the plugin's native translation.

  • /themes - contains translations of themes. Translation file must have the format: theme_name-local.mo, for example: twentyfifteen-ru_RU.mo. As well as with plugins - these files have a higher priority than native theme translation files.

The arbitrary directories

In /wp-content you can create any directories. Some plugins, create such folders for storing files. Usually an additional folder is created when you need to store a lot of files or when the stored files are somehow different from the default WP files.

For example plugin WP Super Cache creates directory /wp-content/cache to store cached pages. Cached page - this is a generated page of the site, stored as a static HTML file. When such page is accessed, it is not re-generated, but a static file is given. This is the page cache, which reduces the server load dozens of times, because pages are not generated on every crawl, and are created only when the cache is overwritten.

The WP Super Cache plugin also adds two files to the wp-content directory: advanced-cache.php (special) and wp-cache-config.php. They are needed for WP Super Cache to work.

Another example, a popular gallery plugin - NextGen Gallery - creates a directory /wp-content/gallery to store images uploaded to galleries. Each gallery created is a subdirectory of /gallery.

Another example, my plugin Kama Thumbnail, which also creates a folder /wp-content/cache/thumb and writes created thumbnail files into it.


Special files


Called at the earliest stage of loading WordPress, in the wp-settings.php file, if the WP_CACHE constant is enabled. This is what the call looks like:

 * Filters whether to enable loading of the advanced-cache.php drop-in.
 * This filter runs before it can be used by plugins. It is designed for non-web
 * run-times. If false is returned, advanced-cache.php will never be loaded.
 * @since 4.6.0
 * @param bool $enable_advanced_cache Whether to enable loading advanced-cache.php (if present).
 *                                    Default true.
if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) && file_exists( WP_CONTENT_DIR . '/advanced-cache.php' ) ) {
	// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
	include WP_CONTENT_DIR . '/advanced-cache.php';

	// Re-initialize any hooks added manually by advanced-cache.php.
	if ( $wp_filter ) {
		$wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter );

This file is used by page caching plugins. It usually checks for a suitable cache file, and if there is one, it is displayed and the script is terminated. This allows you not to load 90% of WordPress files and give static HTML files.



Called from function wp_start_object_cache(), which in turn is called from the wp-settings.php file, a little later advanced-cache.php. Unlike advanced-cache.php, object-cache.php is always triggered if it exists. It is needed to override the operation of basic WordPress object caching.

The object caches based on this file are Memcache, Redis, Memcached, APC, XCache.

The call looks like this:

// Starts WordPress object caching or external object caching if a special file exists.


wp-content/maintenance.php is responsible for displaying a stub page that is shown when WoordPress auto-updates. Such a page is defined by default and the wp_maintenance() function is responsible for it. But if you create a file maintenance.php in wp-content, then the contents of that file will be responsible for the page's output.

In maintenance.php you need to describe the maintenance-page according to all HTML rules.

See function wp_maintenance() for details.


Allows you to display an arbitrary database error page template.

If the wp-content/db-error.php file exists in the wp-content, then this file will be loaded instead of the default WordPress database connection error message. In the file you need to create HTML code for the error page!

The connection error page should set the 500 response status, so that search engines do not process content.

File db-error.php is called by function dead_db(), and the function in turn is called when the database connection error occurs.

An example of such a page:

  // custom WordPress database error page
  // Edit by Kolshix

  // error variations
  // 500 software works, but there are serious internal problems that prevent queries from being processed correctly.
  // 503 indicates a large queue of requests on the server - when the server is overloaded there can be problems with the connection to the database

  header('HTTP/1.1 503 Service Temporarily Unavailable');
  header('Status: 503 Service Temporarily Unavailable');
  header('Retry-After: 600'); // 1 hour = 3600 seconds // inform the bot that it should try again after the set time

  // admin email notification
  // mail( 'your@email.com', 'Database Error', 'There is a problem with the database!', 'From: Db Error Watching');

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Database Error</title>
				setTimeout( "window.location.reload()", 9000 );

			<h1>Error Connection</h1>
				a.button {
					color: white;
					text-decoration: none;
					user-select: none;
					background: rgb(76, 144, 232);
					padding: 9px;
					outline: none;
					border: 3px solid #3d6ea0;
					border-radius: 10px;
				a.button:hover  { background: rgb(86, 218, 72); }
				a.button:active { background: rgb(76, 144, 232); }

			<script type="text/javascript">
				function timer(){
				var obj=document.getElementById('timer_inp');
					if (obj.innerHTML==0){
					} else {

			<h1><div>Wait: <span id="timer_inp">9</span> Or <a href='<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"]; ?>' class="button">Refresh</a></div></h1>
			<img itemprop="url" src="/err_c.gif" width="300" height="300" >


Only loaded for multisite builds, i.e. when is_multisite() is triggered and SUNRISE constant is defined (it should be defined in wp-config.php).

File wp-content/sunrise.php allows you to change the logic of the site at an early stage in the network multisite. For example, here you can set global variables $current_site, $current_blog defining the current network site. Or you can change the prefix of the database tables - the variable $table_prefix.

Also in the unrise.php file you can change the constants that are responsible for where the directories of MU plugins or ordinary plugins are located. See wp_plugin_directory_constants().

sunrise.php connects even before SHORTINIT constant.

sunrise.php is connected in the wp-includes/ms-settings.php file, which in turn is connected in the main loading wp-settings.php file.



Allows you to rewrite the database engine. If the file exists in the wp-content folder, it will be called before creating a connection to the database. Further, if in this file variable $wpdb is defined, then it will be used as a global variable for work with the database.

With this logic, you can, for example, extend the base class wpdb{} or replace it completely.

An example of an extension for the base wpdb{} class.


// this is code for the db.php file, which is in the wp-content folder

defined( 'ABSPATH' ) || die();

if ( defined( 'DOING_CRON' ) && DOING_CRON )

class MY_DB extends wpdb {

	public function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {

		// additional code...

		parent::__construct( $dbuser, $dbpassword, $dbname, $dbhost );


	// redefining the wpdb::query() method
	public function query( $query ) {

		// our modified code



Renaming or moving the wp-content folder

In some cases, for example, to unique many URLs of your site, or to combine site structure with another script, or for some other reason, it is necessary that the directory wp-content have a different name or that it is located in a different directory.

Moving or renaming wp-content is very simple. To do this, open the wp-config.php configuration file, which is in the root of your site, and define in it two constants:

  • WP_CONTENT_DIR - the path to the content directory.
  • WP_CONTENT_URL - URL to the content directory.
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] .'/data' );
define( 'WP_CONTENT_URL', 'http://'. $_SERVER['HTTP_HOST'] .'/data' );

This code renames wp-content to data.

No comments
    Log In