Do you want to learn about WordPress file and directory structure? The core WordPress software, themes, plugins, and user uploads are all stored on your website. In this beginner’s guide, we will explain the WordPress file and directory structure.
Why You Should Learn About WordPress File and Directory Structure?
Most users can run their WordPress site without ever learning about WordPress files or directories. However, understanding how WordPress stores files and directories can help you solve many common WordPress problems on your own.
This guide will help you:
- Learn which WordPress files and folders are core files.
- Understand how WordPress stores your images and media uploads.
- Where WordPress stores your themes and plugins.
- Where configuration files are stored on your WordPress install.
This information also helps you learn which WordPress files should you backup.
Having said that, let’s take a look at WordPress file and directory structure.
Accessing WordPress Files and Directories
An easier alternative to FTP is File Manager. It is a web based application that comes built into cPanel dashboard of your WordPress hosting account.
Once you have connected to your WordPress site either using FTP or File Manager, you will see a file and directory structure that looks like this:
Files and folders in the red squares are the core WordPress files. These are the files and folders that run your WordPress site. You are not supposed to edit those files on your own.
Here is a list of core WordPress files and folders you would see in your WordPress site’s root directory.
- [dir] wp-admin
- [dir] wp-includes
WordPress Configuration Files
Your WordPress root directory contains some special configuration files. These files contain important settings specific to your WordPress site.
- .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. It also sets some global settings for your WordPress site.
- index.php – The index file basically loads and initializes all your WordPress files when a page is requested by a user.
You may need to edit wp-config.php or .htaccess file sometimes. Be extra careful when editing these two files. A slight mistake can make your site inaccessible. When editing these two files, always create backup copies on your computer before making any changes.
If you don’t see .htaccess file in your root directory, then checkout our guide on why you can’t find .htaccess file in your WordPress root directory.
Depending on how your WordPress site is setup, you may or may not have the following files in your root directory.
- robots.txt – Contains instructions for search engines crawlers
- Favicon.ico – A favicon file is sometimes generated by WordPress hosts.
Inside wp-content Folder
WordPress stores all uploads, plugins, and themes in wp-content folder.
It is generally assumed that you 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 your theme files in
/wp-content/themes/ folder. You 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 you download and install on your site are stored in /wp-content/plugins/ folder. You are not supposed to edit plugin files directly, unless you wrote the plugin just for your own WordPress site.
In many WordPress tutorials, you will see code snippets that you can add to your WordPress site. The best way to add custom code to your WordPress site is by adding it to functions.php file of your child theme or by creating a site-specific plugin.
WordPress stores all your image and media uploads in the
/wp-content/uploads/ folder. By default, uploads are organized in
/year/month/ folders. Whenever you are creating a WordPress backup, you should include uploads folder.
You can download fresh copies of WordPress core, your theme, and installed plugins from their sources. But if you lose your uploads folder, then it would be very hard to restore it without a backup.
Some other default folders you may see in your 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 your wp-content folder. For example, in the screenshot above we have a gallery folder created by Envira Gallery plugin.
Some of these folders may contain important files. Like the gallery folder may contain your gallery images. You should always backup such folders to avoid losing important data.
That’s all, we hope this article helped you understand WordPress file and directory structure. You may also want to see our beginner’s guide to WordPress database management with phpMyAdmin.
The post Beginner’s Guide to WordPress File and Directory Structure appeared first on WPBeginner.