The core WordPress software, themes, plugins, and user uploads are all stored on our website files and directories.
Most novice to experienced users run their WordPress site without ever knowing about WordPress files or directories structure. However, understanding how WordPress stores files and directories will help solve many common problems on our own.
In this tutorial we will,
- Learn which files and folders are core files.
- Understand how images and other media uploads are stored.
- Where themes and plugins are stored.
- Where configuration files are stored.
- which WordPress files to backup.
- Perform troubleshooting tasks like deactivating all plugins, switching to a default theme, or fix other common errors.
To view WordPress files and directories, you can either connect to your wordpress site using FTP or you can download a fresh WordPress from wordpress.org and extract to the folder of your choice and open the extracted wordpress folder to view the following structure.
Among those files core WordPress files and folders we would see are,
- [dir] wp-admin
- [dir] wp-includes
We are not suppose to edit these files on our own.
Any WordPress root directory contains some special configuration files that store important settings specific to our site.
Here are the important configuration files,
- .htaccess – A server configuration file, WordPress uses it to manage permalinks and redirects.
- wp-config.php – This file tells WordPress how to connect to your database and also sets some global settings for our website. If you have freshly downloaded the wordpress from wordpress.org you will not see this file. This is created when you install WordPress or you can copy wp-config-sample.php and enter your settings directly.
- index.php – The index file basically loads and initializes all our WordPress files when a page is requested by a user.
WordPress stores all uploads, plugins, and themes in wp-content folder.
It is generally assumed that we can edit files and folders inside wp-content folder. However, this is not entirely true.
Let’s take a look inside wp-content folder to understand how it works and what you can do here.
The contents of wp-content folder may differ from one WordPress site to another. But all WordPress sites usually have these:
- [dir] themes
- [dir] plugins
- [dir] uploads
WordPress stores our theme files in /wp-content/themes/ folder. We can edit a theme file, but it is generally not recommended. As soon as you update your theme to a newer version, your changes will be overwritten during the update. This is why it is recommended to create a child theme for WordPress theme customization.
All WordPress plugins we download and install on our site are stored in /wp-content/plugins/ folder. We are not supposed to edit plugin files directly, unless its our own.
WordPress stores all our image and media uploads in the /wp-content/uploads/ folder. By default, uploads are organized in /year/month/ folders. Whenever we are creating a WordPress backup, we should include uploads folder.
We can download fresh copies of WordPress core, our theme, and installed plugins from their sources. But if we lose our uploads folder, then it would be very hard to restore it without a backup.
Some other default folders we may see in our wp-content directory.
- languages – WordPress stores language files for non-english WordPress sites in this folder.
- upgrade – This is a temporary folder created by WordPress during upgrade to a newer version
Many WordPress plugins may also create their own folders inside our wp-content folder.
Some of these folders may contain important files. Wou should always backup such folders to avoid losing important data.
Other folders may contain files that we can safely delete. For example our caching plugins like W3 Total Cache or WP Super Cache may store cached files in their own folders.