WordPress Architecture: Understanding the Website Structure, Common Files, and Directories

As a CMS, WordPress offers great flexibility in customizing the look and functionality of your website. The software also lets you boost the search engine optimization of your WordPress website for a higher ranking.

However, doing so requires having some knowledge of the WordPress website architecture. Knowing the purpose and location of your WordPress files and directories helps you customize and troubleshoot the website when encountering an unexpected issue.

With this in mind, we will explore the WordPress architecture in more detail. By the end of this article, you will better understand the backend of your WordPress website and be able to navigate through it if needed.

Download all in one WordPress cheat sheet

Understanding the WordPress Website Architecture

When installing WordPress for the first time, a set of the CMS core folders and files are uploaded to the web server. The folder that hosts all these files is called public_html or the root directory, and it’s one of the most significant elements of your WordPress website.

You can access the root directory and its content through your web host’s File Manager. Alternatively, browse the backend of your WordPress site by connecting your server to an FTP client like FileZilla.

The content of a root directory, seen through Hostinger's File Manager

The basic WordPress core files and folders define the appearance, functionality, and security aspects of your site architecture. These PHP files are connected to each other and the WordPress database.

Pro Tip

To avoid breaking the website, we recommend learning each file’s function and backing up the site first. Setting access rights for WordPress files and folders also helps to reduce security risks.

Common WordPress Template Files

Each new WordPress installation comes with a pre-installed default theme. WordPress stores all the assets and files of your installed themes in the wp-content -> themes folder. To modify each WordPress theme, you need to make changes to their respective template files.

Locating the Themes folder inside the root directory

Different WordPress themes have different sets of assets and template files. However, most WordPress templates utilize the following page template files to create their design and functionality.

index.php

This PHP file is responsible for displaying your home page when users access your website. As the main template file in the template hierarchy, index.php is the fallback file that WordPress automatically loads when it cannot find the requested template file.

If the index.php file is missing, WordPress will display the content of your root folder on the visitor’s browser, creating a bad user experience and a massive security risk.

header.php

As the name implies, this file defines the elements within the header section of your site. If you want to customize your website logo, navigation links, or search bar, this is the file you’d want to edit.

The header.php file can also host the tracking code if you want to keep track of your site’s performance. Add Google Analytics to your WordPress website by inserting the JavaScript code above the </head> closing tag of your active theme’s header.php file.

This template file displays the footer section of your site. Many WordPress admins use their website’s footer to boost search engine optimization (SEO) efforts, promote social channels, and display the sitemap.

Like its counterpart, it can also host custom JavaScript code for tracking purposes. Various WordPress plugins like MonsterInsights and WPCode make adding code snippets to the header and footer of your site easier.

functions.php

This is the template file to edit if you want to add your own custom features to the WordPress theme. The functions.php file is particularly useful for web developers and admins who want to expand the site’s functionality without installing a plugin.

If your WordPress theme doesn’t use this PHP file, you can create one inside your theme’s folder. However, all functions added to this file will stick to that specific theme, meaning they’ll be disabled if you switch to another theme.

style.css

The stylesheet dictates your website’s visual design and layout. Without this file, your website will only display the web pages in plain HTML text.

You can add custom CSS to WordPress using the built-in block editor or a plugin like Simple Custom CSS or WP Add Custom CSS.

Important WordPress Installation Files and Folders

After learning the files that make up your website’s front end, let’s move to the backend side. The following are essential WordPress folders and files that ensure your website runs properly.

.htaccess

The .htaccess file is a configuration file for the Apache web server access control. It’s a critical WordPress core file that enables and disables the features of your website and certain plugins. You can also use it to manage redirects and permalinks.

WordPress automatically creates a .htaccess file on the root directory of websites hosted on an Apache web server. However, it’s usually hidden to minimize security risks. If one doesn’t exist, you must locate it or create a new .htaccess file.

wp-config.php

The wp-config.php file is responsible for establishing a connection between WordPress and the MySQL database. Without it, your website won’t be able to store and retrieve data from its database.

This configuration file stores all the data needed to access the site’s database, such as the database username, password, and host. WordPress stores it inside the root folder by default. However, relocating the file to a less predictable directory is a great security practice for preventing hacking.

robots.txt

The robot.txt file has a significant role in your SEO efforts. It contains a set of instructions for search engines’ crawlers not to index certain parts of your web pages.

While WordPress creates a robot.txt file inside your root directory, it needs modifications to function optimally. For example, you can add rules to block crawlers from indexing blog category pages, blog author pages, and 404 pages.

WordPress SEO plugins like Yoast SEO and All In One SEO Pack make creating and editing the robot.txt file hassle-free if you don’t want to do it manually.

wp-content

This WordPress core folder dictates what users see when accessing your website. It contains all the plugin and theme files and uploaded media, such as video and image files.

As the wp-content directory stores all the website content that the database can’t handle, we recommend backing it up regularly to avoid losing your hard work.

Conclusion

Any WordPress website owner should understand how WordPress functions to optimize the site and debug errors without professional help.

Remember to back up your website before changing any WordPress core files. Doing so will prevent data loss when encountering a site-breaking error during the coding process.

We hope this article has helped you better understand WordPress’s common template files and essential installation files and folders. Leave a comment below if you have any questions.

Author
The author

Jordana Alexandrea

Jordana is a Senior Content Writer at Hostinger with a background in Information Systems. She has over five years of experience in WordPress and is casually dabbling with PHP and MySQL. Her passion for writing and technology drives her to create tutorials for anyone wanting to build their online presence. Follow her on LinkedIn.