WordPress File and Directory Structure: A Comprehensive Guide

Table Of Content

If you are an entry-level developer and afraid of complex industry jargon like “WordPress File” and “Directory structure”, don’t worry; we are here to make things easy for you.

Understanding the WordPress file and directory structure is crucial for developers, designers, and administrators to effectively manage and customize their websites. So, let’s begin our exploration of the WordPress file and directory structure to unlock the full potential of this powerful CMS. To delve deeper into the WordPress file and directory structure, you can refer to the official WordPress documentation. It provides detailed information on each component and how they work together to create a WordPress site.

So our expert WordPress developers have compiled this guide to provide you with every bit of info about the WordPress file and directory structure. You’ll see and learn about all the different files and folders required to ensure your WordPress website works perfectly.

What is WordPress File & Directory Structure?

First, let’s see what the WordPress file and directory structure is. 

It refers to the organization and arrangement of files and folders within a WordPress installation. It shows where the different components of the WordPress system, like core files, themes, plugins, media uploads, and configuration files, are located.

The file structure in WordPress plays a crucial role in how the CMS functions. It can also support how developers and site administrators operate their websites. A better understanding of WordPress files and directory structure allows users to locate specific files, make modifications, add custom code, install themes & plugins, and manage site content effectively.

By following a consistent structure, WordPress ensures that files are organized logically, making it easier to maintain and update the Content Management System. The structure also separates core files from site-specific content and facilitates upgrades without affecting customizations.

WordPress files and directories are available on the web hosting server that you can access using an FTP client. As an alternate approach, WordPress files and directories are also accessible through the file manager in the WordPress Hosting control panel.

wordpress hosting control panel

The WordPress file and directory structure is split into four parts:

wordpress file and directory structure
  • WordPress Configuration Files
  • wp-admin [dir]
  • wp-includes [dir]
  • wp-content [dir]

When you first download WordPress from the official website, these files and directories are already in the Zip file. All you need to do is to extract them and upload them to the host through FTP (File Transfer Protocol).

In the following sections, we’ll look at WordPress files and directories in detail.

WordPress Configuration Files

WordPress configuration files contain the settings and parameters crucial for your WordPress CMS and website to operate properly. These files help configure several aspects of a website, including security keys, language preferences, database connectivity, debugging settings, and so on. 

The fundamental WordPress configuration files are as follows:

.htaccess

The .htaccess is a server configuration file located in the root directory of your WordPress website. It contains and dictates the rules about how a web server should function and operate. This file lets you modify and configure the server-level settings, along with some other use cases, like URL rewriting, security enhancement, caching and compression, and server-level redirects. 

.htaccess file in file manager

When you are trying to make the URLs more readable, you’ll need to navigate to Settings > Permalinks and select the URL structure. Then, the .htaccess file will be automatically rewritten to handle the URL structure. 

In the case of the .htaccess file, the dot at the front means it is hidden. But you can access it with the file manager or FTP client in the control panel of your WordPress website host.

Although manual editing of the .htaccess file is possible, it can be a risky endeavor. Sometimes, when WordPress is not able to write the .htaccess file, it may ask you to write it manually instead. In that case, make sure you copy the contents provided by WordPress precisely as they are.

wp-config.php

wp-config.php file in file manager

Located in the root directory, wp-config.php is the primary configuration file critical for a smooth WordPress installation. Although not built-in, this file is generated for your website during the installation.

Among the most significant highlights of this file is that it contains the parameters and settings for establishing a stable connection between WordPress and the database. A few other key aspects of the wp-config.php file are unique authentication keys and salts and database table modifications (for security enhancements). It also allows for debugging and error reporting and defining additional constants (for setting the maximum memory limit and specifying the default theme).

The wp-config.php file contains a lot of sensitive info about the website, including the security keys and database credentials. That’s why you need to ensure this file is inaccessible to unauthorized users and that there are suitable file permissions in place for extra protection. 

index.php

index.php in file manager

The index.php file serves as the primary starting point for a WordPress website, acting as the initial file that is accessed when someone visits the site. This file is used for bootstrapping, content rendering, and customizations (with respect to the layout, design, and content on the page).

It’s very important to understand index.php for modifying the homepage or default posts page of your WordPress website. However, you’ll be better off using child themes or theme customization options rather than going for index.php file modification. The theme templates help ensure compatibility with future theme updates.

Understanding the .htaccess, wp-config.php, and index.php means complete control over your WordPress website. They can help you customize, troubleshoot, and protect your website (through extensive security implementations). You can also optimize the website’s performance and maintain and upgrade it effortlessly. 

WordPress Directory Folders

After the configuration files, we move to the key directories, i.e., wp-admin, wp-includes, and wp-content. The primary aim of the file and directory structure is to organize and manage the wide variety of contents and components of a WordPress website. 

So let’s discuss these directories in detail:

wp-admin

wp-admin directory

This directory serves as a gateway to the dashboard or administration of your WordPress website. Basically, this directory consists of the files and resources powering the back end of a WordPress website. That allows the website owners and developers to control various aspects of the website.

One of the significant purposes of the wp-admin folder is that it houses the PHP files necessary for rendering and modifying the user interface for the WordPress dashboard. So the developers and owners can easily create and edit the posts and pages, and manage the media files. They can also configure the themes and plugins, control user permissions, and customize other website settings.

This directory folder also hosts the files for core administrative operations, which helps handle the critical back-end functions of the website. These functions include data interactions, administration task execution, user authorization and authentication, and even HTTP request handling. 

There are seven subfolders within the wp-admin folder:

  • css: The CSS or Cascading Style Sheets folder contains the files for defining the visual styling and layout of the WordPress dashboard. With these CSS files, you can control the presentation of elements like buttons, menus, forms, and overall dashboard aesthetics.
  • images: This subfolder stores image files like logos, icons, backgrounds, and other visual aspects used within the WordPress dashboard. They can help with the best visual representation of all elements in the admin area.
  • includes: This subfolder contains several PHP files crucial for providing essential functionalities like user authentication, localization, database interactions, session management, and more for the WordPress dashboard. 
  • js: As the name suggests, this subfolder contains JavaScript files used for enhancing the interactivity and functional proficiency of the WordPress dashboard. 
  • maint: The maint subfolder is used during maintenance operations, including WordPress website updation and comprehensive system maintenance. 
  • network: It is one of the most significant subfolders if you are trying to manage multiple sites.
  • user: Although it isn’t present in all WordPress installations, the “user” subfolder can help with user-specific functionalities or customizations within the dashboard.

From css to js to user, these wp-admin subfolders can organize files related to styling, images, back-end operations, interactivity, maintenance, multisite functionality, and user-specific features. Thus they may prove to be significant for the visual representation, overall functionality, and user exp. of the WordPress admin area.

Other than the subfolders, there are several important files in the wp-admin directory:

  • admin.php: Serving as the entry point for the WordPress admin area, the admin.php file includes significant files to display and manage the back-end by initializing the necessary functions.
  • index.php: As the default index file, index.php prevents direct access to the contents of the wp-admin folder by redirecting the users to the login page.
  • install.php: Upon initially setting up WordPress, the install.php file guides you through the installation process. So you can provide the necessary details like database connection information for your WordPress site accordingly.
  • plugins.php: The plugin.php file helps manage the plugins installed on your WordPress website. The interface provided by this file lets you install, delete, activate, or deactivate plugins more easily.
  • themes.php: The themes.php file helps manage the themes installed on your WordPress website. So you can check and configure the theme settings more easily.
  • users.php: With this wp-admin file, you can manage the user accounts and permissions on your WordPress site. Moreover, with its user-friendly interface, you can create, edit, or delete user accounts, assign user roles, and configure user-related settings (including the profiles and passwords).

These files are crucial for administering and managing a WordPress site. They enable you to oversee different aspects of your website, including functionality, appearance, and user access.

wp-includes

wp-includes directory

The wp-includes directory is among the most significant components of the WordPress installation, containing the core files (other than the ones for admin functions and themes and plugins) necessary for the smooth functioning of the WordPress website. This directory contains the files defining PHP classes. These classes are reusable code structures containing specific functionalities and can be considered as the building blocks for WordPress to perform critical tasks like database interactions, data validation, template handling, and more. 

Additionally, the wp-includes directory holds PHP files that define numerous functions used throughout the WordPress core. These functions perform a wide range of operations, including handling database queries, managing security measures, generating HTML output, and facilitating plugin/theme integration.

Then there’s the “JS” subdirectory containing the JavaScript files necessary for enabling the interactive elements of a website. There are several other subdirectories within wp-includes that are responsible for functions like template handling, script loading, text difference comparison, and more. 

Overall, the files and subdirectories within wp-includes are a part of the fundamentals of WordPress. They deliver the core features and functionalities to create one of the best CMSs. 

wp-content

wp-content directory

Last but not least, we have the wp-content directory that stores the themes, plugins and other site-specific file content of your WordPress website. As a fundamental part of the WordPress installation, you’ll most probably spend most part of your development and customization time on this directory. 

Now, let’s discuss the crucial subdirectories of wp-content.

[dir] themes

As the name suggests, this subdirectory stores the crucial files for every theme you install on your WordPress website in separate subfolders. In every one of these subfolders, there will be a collection of .php and other files that act as the building blocks of that particular theme. 

Here are a few important files as a part of the themes subdirectory.

  • index.php – As the main template file, index.php is used to show the content of the home and other pages of your website.
  • style.css – The style.css file defines the visual styling and appearance of the theme’s elements, such as fonts, colors, layouts, and other design aspects.
  • functions.php – Containing the theme’s functions, the function.php file can be used to extend the functionality of the theme by adding custom features, modifying existing functionalities, or integrating external services and APIs.
  • header.php – Containing the header section of the theme, the header.php file renders the header section of a webpage, including the site title, navigation menus, logo, and more.
  • footer.php – The footer.php file controls the display of the footer section of a webpage. That typically includes website navigation, copyright info, social media icons, and more.
  • sidebar.php – The sidebar.php file renders the sidebar section of a webpage. It is commonly used for displaying navigation menus, recent posts, widgets, search bars, and other content appearing alongside the main content on a webpage.
  • page.php – The page.php template file controls the layout and display of individual pages of the WordPress website.
  • single.php – The single.php template file renders the individual posts on a WordPress website.
  • singular.php – The singular.php file renders any singular content to provide a consistent layout and design for individual content items on a website.
  • archive.php – The archive.php file displays a list of posts or content grouped by specific criteria in a consistent manner.
  • search.php – The search.php file controls the layout of search results pages and displays the posts or content relevant to the user’s search query.
  • category-{slug} / category-{id}.php – The category-{slug}.php or category-{id}.php files allow design and layout customizations of specific category archive pages. So the posts belonging to a particular category are displayed consistently based on either the category slug or ID.
  • Tag-{slug} / tag-{id}.php – The tag-{slug}.php or tag-{id}.php file displays the posts associated with a particular tag. So when a visitor clicks on a tag link, WordPress uses the tag.php template file to display all posts that have been assigned to it.
  • 404.php – The 404.php file displays a custom “404 Not Found” error page in case a user tries to open a non-existent or unavailable page on the website.
  • [dir] inc/ – This subdirectory contains additional files and folders for the theme. These files and folders handle specific features, custom post types, or reusable functions to enhance the capabilities of a theme. 
  • [dir] assets/ – This subdirectory stores static assets such as CSS files, JavaScript files, images, fonts, and more. They are necessary for the visual presentation and functionalities of the theme.
  • [dir] js/ – This subdirectory contains the theme’s JavaScript files that allow for the inclusion of interactive and dynamic functionalities on the website.
  • [dir] languages/ – This subdirectory stores language and translation files enabling the display of the website content in different languages. That enhances the accessibility and user experience for multilingual audiences.

All these files and subfolders are necessary to ensure the best appearance and functionality of the themes installed on your WordPress website. 

How to Create a Tailor-Made Theme for Your WordPress Website?

Now that you know about all the crucial subfolders and files of a theme, you can try a custom one for yourself (or for public use). Let’s see the step-by-step guide for the same:

Step 1: Create a new subfolder in the wp-content/themes directory of your WordPress installation. It will act as the primary location or directory for your custom theme.

Step 2: Then, create a new file and name it style.css in the main directory of your theme.

Step 3: After that, add the following code at the top of your style.css file:

   /*
   Theme Name: [Your Theme Name]
   Author: [Your Name]
   Author URI: [Your Website URL]
   Description: [A brief description of your theme]
   Version: [Theme Version Number]
   */

Note: Make sure you replace the placeholders with the corresponding information about your theme.

Step 4: Next, create another file named index.php in the main directory. That will help display the homepage of the theme.

Step 5: Then, create the file functions.php, where you can add your custom code for the new theme. 

These steps will help create a new, custom theme for your WordPress website in no time at all. But if you need some significant customizations on your theme, you may opt for our WordPress theme development services

[dir] plugins

Just like the themes, every plugin on your WordPress website will have its own subfolder in the plugin subdirectory. For every plugin, the contents of its folders will vary depending on the functionalities and more. 

So let’s check out some of the important files as a part of the plugins subdirectory.

  • plugin-name.php – This is the main PHP file of any WordPress plugin installed on the website and contains the PHP code defining the plugin’s functionality. It also provides the necessary functions and classes to extend or modify the features and functionalities of the website.
  • uninstall.php – WordPress finds and executes the uninstall.php file when a plugin is uninstalled and deleted via the “Plugins” screen in the dashboard. That allows for custom cleanup tasks like removing plugin-specific database tables, options, or any other resources associated with the plugin.
  • readme.txt – The readme.txt file contains details about the plugin, including the version, features, installation instructions, changelog, and more for the website developers.
  • [dir] languages/ – This directory stores the language and translation files as .mo and .po. That enhances the accessibility and user experience for multilingual audiences.
  • [dir] includes/ – This directory contains any additional PHP files the plugin requires, such as helper functions, class files, or configuration files. That promotes code organization and modularity.
  • [dir] assets/ – This directory contains any static assets used by the plugin, such as images, CSS files, fonts, JavaScript files, and more. These files ensure a better visual display and enhanced functionalities of the plugin.
  • [dir] templates/ – This directory stores the template files used by the plugin to display content. These template files include custom post-type templates or shortcode templates and ensure easier customization and maintenance down the line. 
  • [dir] vendor/ – This directory stores the third-party libraries or dependencies utilized by the plugin, including PHP packages or JavaScript libraries. That ensures proper versioning and updation of these dependencies.
  • license.txt – This file stores and displays the information licensing terms and conditions under which the theme or plugin is distributed. That includes the restrictions and permissions per the users. 

All these files and subfolders are necessary to ensure the plugins can extend the capabilities of your WordPress website through new features, functionality, or integrations.

How to Create a Customized Plugin for Your WordPress Website?

Now that you know about all the crucial subfolders and files of a plugin, you can try a custom one for yourself (or for public use). Let’s take a look at the stepped guide for the same:

Step 1: Create a new subfolder in the wp-content/plugins directory of your WordPress installation. It will act as the primary location or directory for your custom plugin.

Step 2: Then, create a new file in the text editor. Save it with the name of your custom plugin in your plugin folder with a .php extension.

Step 3: After that, add this code at the top of your plugin file:

<?php
   /*
   Plugin Name: [Your Plugin Name]
   Description: [A brief description of your plugin]
   Version: [Plugin Version Number]
   Author: [Your Name]
   Author URI: [Your Website URL]
   */
   // Your plugin code goes here
   ?>

Note: Make sure you replace the placeholders with the corresponding information about your plugin.

Step 4: Write the code for your custom WordPress plugin and save it.

Step 5: Go to your WordPress dashboard, and click on the Plugins. 

Step 6: Finally, look for your new custom plugin in the list of custom plugins and activate it. 

Now, you’ll be able to customize the features and functionalities of your website through your new custom plugin. 

If you want more customization in existing WordPress plugins, then recommended consulting with a WordPress plugin development company, that will help you with your requirements.

[dir] uploads

This subdirectory or folder stores the files uploaded on the website by the visitors and users. Everything you see in this folder is directly correlated to the site’s media library. The files uploaded by the visitors are stored in yearly and monthly folders so that they can be retrieved more easily.

So when you or the visitor upload any type of file to your WordPress website, the CMS automatically stores it in the uploads folder and categorizes it by year and month. So you’ll be able to access the files more easily whenever necessary. 

Without the uploads directory, your website won’t be able to display any images, videos, or any other media file.

However, since every file uploaded on the website is stored in this subdirectory, it can take up a lot of disk space. So you may want to check the folder and delete any unnecessary files periodically. 

Moreover, some plugins can help optimize and compress your media files. That will help reduce the disk space taken by the uploads folder.

[dir] upgrade

This temporary folder is created whenever you upgrade to a newer version of WordPress. 

That concludes the directories that control and manage the different types of contents and components of a WordPress website. Make sure you keep the file and directory structure shown above as it is. Otherwise, it may result in a host of issues with the website with respect to functionality, theme and plugin compatibility, usability, maintenance, and more. 

Why Learn About the WordPress File & Directory Structure?

Everything you have learned so far from this blog may seem a little daunting. So you may think, “What’s the point in learning all this?”. Well, here are some reasons that may justify your learning about this file and directory structure:

  • You can take care of the minor issues with the themes and plugins (like disabling them) by yourself.
  • In case of any issues, this knowledge can help you sift through advice from different sources and decide on the best solution accordingly. Moreover, you can even consult a WordPress development company and tell them exactly what kind of issue you have been facing. That will help save some time.
  • With this additional know-how, you’ll be able to create, customize, upgrade, and maintain your WordPress website better and more efficiently.
  • You won’t accidentally delete any critical files (or make any unintentional changes to them). That will help prevent any website crashes.

Overall, creating and managing a WordPress will be much easier with this info about the file and directory structure. And anyway, there’s always an option to hire WordPress developers in case you need any help with the process. 

Conclusion

We created this blog for anyone confused about what goes on behind the scene on any WordPress website. How does this CMS store and manage the info and details regarding any website? The WordPress file and directory structure consists of the configuration files that contain the .htaccess, wp-config.php, and index.php. Then there are the directory folders consisting of the wp-admin, wp-includes, and wp-content

The wp-admin directory contains all the crucial files and resources powering the WordPress admin area or dashboard, allowing the website administrators to manage and configure the website effectively. The wp-includes directory contains the core WordPress files. That includes the libraries, functions, and classes providing foundational functionality for WordPress. And last but not least, the wp-content directory stores the themes, plugins, media uploads, and other user-generated content. That allows for better customization of the WordPress website beyond the core features and functionalities.

We hope to have satisfied you with this information about the WordPress file and directory structure. For any other query regarding WordPress, you can choose our 30 min free consultation by contacting our experts.

author
Jigar Shah is the Founder of WPWeb Infotech - a leading Web Development Company in India, USA. Being the founder of the company, he takes care of business development activities and handles the execution of the projects. He is Enthusiastic about producing quality content on challenging technical subjects.

Leave a comment