The Beginner Guide to WordPress File and Folder Structure

WordPress, which currently empowers nearly 40% of all websites on the Internet, proves the most popular system to host your content. Users love its ease of use, flexible customization, and a great deal of supportive plugins. You can build your own site without any coding skills and knowledge.

As a matter of fact, WordPress is not just a website-building platform. You’re recommended to dive into deeper learning to manage your site more efficiently. WordPress file structure turns out to be one of the most important things to pay attention to.

Understanding the file and folder structure lets you complete common tasks in less time and less stressfully.

In today’s post, we’ll give you a clear picture of what WordPress files and folders are, how they are organized on the server, and their functionalities. We’ll also show you how to change file and folder permission.

Let’s dig in!

What Are WordPress Files and Folders?

Once you install your WordPress website, it locates a list of the files on your site and at the same time creates a database. It refers to the foundation of your site which defines how your site works properly. If there is a missing file or a small action taken on a single file, it will lead to huge problems or even shut your entire site down.

First, getting to know WordPress file structure well makes it convenient for you to manage your site. You’ll have full control over your site elements including media, themes, plugins, and content, etc.

Besides, you can quickly detect errors and fix issues. Take a buggy plugin as an example. It conflicts with other plugins or themes, which may lock you from the admin dashboard. The only way to solve this is to open the WordPress server and delete it.

You’re also able to know how WordPress stores media files such as images, videos, and audio. They include both files you upload to the library and files uploaded by users from the frontend. This gives you a great chance to protect or control user access permission with ease.

Plus, before making any changes, you can generate backups in the server to secure your files. If the update doesn’t work as your expectation, you can remove the changes and set the site back to its previous status.

Overview of WordPress File Structure and Directories

WordPress server consists of a bunch of files and folders and the root directory. They include 3 main folders and about 20 files. Each file also contains folders and sub-folders. Here is a list of your WordPress installation:

  • WordPress folders
    • The wp-admin folder
    • The wp-content folder
    • The wp-includes folder
  • WordPress files
    • .htaccess
    • index.php
    • license.txt
    • readme.html
    • wp-activate.php
    • wp-blog-header.php
    • wp-comments-post.php
    • wp-config-sample.php
    • wp-config.php
    • wp-cron.php
    • wp-links-opml.php
    • wp-load.php
    • wp-login.php
    • wp-mail.php
    • wp-settings.php
    • wp-signup.php
    • wp-trackback.php
    • Xmlrpc.php

The Structure of WordPress Core Folders

wp-admin, wp-includes, and wp-content come as the three most important files of your WordPress site. Each takes care of different areas on the website, making sure your site works correctly.

wp-admin

The wp-admin file helps manage your WordPress admin dashboard. Anytime someone tries to log into your site from the backend, the file makes sure the provided credentials are correct. Then, it loads the dashboard, connects your database, as well as manages user permission.

This file is located at the first position in the root directory and you have no reason to change any files there. It contains some files managing the admin area, i.e. /css, /images, and about.php, etc.

wp-content

This file includes the Themes and Plugins as its main folders. Every time you install a new plugin, it’ll automatically add a new sub-folder for that plugin there. It depends on the type of plugins you install that the sub-folders will consist of a couple to a bunch of files.

The same thing goes for the Themes folders. Apart from WordPress’s default theme folders like Twenty Twenty, you can add new theme files there. Each theme will have some differences from the others based on its developers. Still, they have some files in common such as functions.php, style.css, index.php, header.php, and footer.php.

Bear in mind that you shouldn’t make CSS changes in your theme and plugin directory. Instead, you can go to ‘Appearance’ → ‘Customize’ → ‘Additional CSS’ in your admin dashboard and place modified snippets there.

If you still wish to modify your style.css file on the server, you can either create a child theme or keep revision copies or backups of your files.

You also have other default folders under the wp-content file, including uploads, upgrade, languages, mu-plugins, cache, and more.

The Uploads folder stores all your media files. Its sub-folders are labeled by the year and month that your files are uploaded. The Upgrades folder, meanwhile, is created when you upgrade your site to a new version. You also have the Languages to keep language files. They translate your site to another language other than English.

wp-includes

wp-includes has a considerably large size with around 22 subfolders. It stores all necessary files to run your WordPress site. It defines your website design and appearance too, for example, fonts, theme-compat, widgets, pages, and posts.

There is a functions.php file in wp-includes which is considered the most important file and also the main WordPress API. You mustn’t edit anything in the core WordPress files in general and the wp-includes file in particular.

WordPress Configuration Files

We’ve walked through three core WordPress folders, it’s time to go over its other important files. WordPress configuration files provide you with vital settings for your site performance and functionality. The most significant ones are htaccess, wp-config.php, and index.php.

.htaccess

Coming as an Apache server configuration file, .htaccess or hypertext access enables operation on a directory level. When you create a subdirectory, this means that you need to have a separate .htaccess file for each of them.

You can make use of the .htaccess file to redirect URLs and manage permalink structure. It helps password protect the WordPress directory and restrict website access by IP addresses too.  Be careful with this file since only one tiny mistake on the .htaccess will instantly shut your site down.

In fact, .htaccess is hidden and can’t be seen in your cPanel. It requires you to go to the cPanel settings and enable the Show Hidden files option.

wp-config.php

The wp-config.php file serves as the bridge between your website and the database. Without the file or its connection function, your site will appear blank with the message “error establishing a database connection.” It stores the database name, password, and use information as well.

To fix the database connection error, you should log into your FTP client and go to the root WordPress folder. Then, edit the wp-config file there, by adding the following code and saving your file.

define(‘WP_ALLOW_REPAIR’, true);

Once done, go to www.yoursitedomain.com/wp-admin/maint/repair.php to repair your database and start the connection process. After making sure your site runs correctly again, go back to the wp-config.php and remove the code above.

Please notice that you must be very careful when touching the wp-config.php file otherwise it destroys the whole site.

The file proves useful when turning on the Multisite feature. It greatly benefits you in changing your site server.

  • index.php

This file works as the WordPress homepage on your site. When a visitor opens your site or browses one of your links, it’ll load all the WordPress files and display them via the requested page or link.

Without an index.php file, users will see your root directory file and folder structure in the exact same way as your sever.

Change File and Folder Permissions

Once understand your WordPress file structure, it’s time to know the access permission. This defines who can read, write, and modify your files. Here are WordPress permission modes:

 7       5    5
user   group  world
r+w+x  r+x    r+x
4+2+1  4+0+1  4+0+1 = 755
  • R – Allow reading files (4)
  • W – Allow writing and modifying files (2)
  • X – Allow executing such as reading writing, deleting, and modifying files (1)

Below is the right set of your WordPress file and folder permission:

  • Folders – 755
  • Files – 644
  • wp-config.php – 600
  • .htaccess – 644, or 600

There may be times that you intend to fix the WordPress file and folder permission to configure the website security. Check out this article on 3 ways to fix WordPress files and folder permission errors.

It includes a simple solution to protect your WordPress media files and folders. Instead of changing media folder access permission in the directory, you can make use of the PDA Gold plugin.

The plugin enables you to secure your upload folders right in the WordPress dashboard. It just takes you a few clicks to restrict folder access from unauthorized users. The detailed tutorial is already included in the above article.

Change Locations of WordPress Folders

It’s possible for you to customize your WordPress file and folder structure by giving them different names or locations. You can change wp-content, plugins, and uploads folders.

After making changes, you’re required to update wp-config.php file so that it can define the new locations. You can do so by adding this code to the wp-config.php file:

define( ‘WP_CONTENT_DIR’, dirname(__FILE__) . ‘/newfolder/wp-content’ );
define( ‘WP_CONTENT_URL’, ‘https://your-site.com/newfolder/wp-content’ );

WordPress File Structure Made Simple

Having a better idea of the WordPress file structure gives you a great chance to troubleshoot errors and customize your site more easily. We’ve listed out the 3 most important WordPress folders along with configuration files.

The wp-admin folder handles the admin area of your site while wp-content includes all your themes, plugins, and uploads. The wp-includes is responsible for anything related to your site appearance, from fonts, sizes to widgets, pages, and posts.

You’re able to change file and folder permissions by setting rules. You can restrict users from reading, writing, or modifying your files. This helps increase site security.

You must always make a copy of the original file and save it before changing anything on the server. The step makes you have a back up your files when the changes don’t work as your expectation.

Do you have any other questions about WordPress file structure? Drop a line in the comment section below so we can discuss it together.

Leave a Reply

Your email address will not be published. Required fields are marked *