WordPress is a popular content management system (CMS) that allows users to create dynamic and visually appealing websites in a matter of minutes. It is also a multi-dimensional CMS that can be used to create a variety of websites, including magazine websites, online portfolios, eCommerce stores, and more. In this article, we will take a closer look at how WordPress works internally and the different components that make up a WordPress installation.
The Internal Functioning of WordPress
At its core, WordPress uses PHP and a SQL database to store all its data. The PHP code makes up the WordPress Core, while the database makes up WordPress’ memory. Every WordPress installation has one database that stores all the information entered by the user, including user information, posts, pages, tags, categories, custom post types, post revisions, drafts, trashed options, comments (approved and unapproved), theme options, and plugin data.
WordPress Folder Structure
The WordPress installation directory contains three main folders: wp_content, wp_includes, and wp_admin. The root directory contains everything except the WordPress database. The wp_includes folder contains all the PHP files and classes required for WordPress’ core operations. The wp_admin folder contains the various files of the WordPress dashboard, where all administrative or functions related to WordPress are done. The wp_content folder contains all user-uploaded data and is divided into three sub-folders: themes, plugins, and uploads.
The themes directory contains all the themes installed in your WordPress site. You can install as many themes as you want but can only activate one theme at a time. The plugins directory is used to store all the plugins installed in your WordPress site. You can activate as many plugins as you like but it’s a good practice to install only the necessary ones. All the images (and other media files) that you’ve uploaded since the time you launched your site, along with all future uploads, will be stored in the uploads directory, categorized by year, month, and day.
The Anatomy of a WordPress Request
When someone visits your WordPress powered website, WordPress dynamically generates an HTML code (combined with CSS and JS) and serves it to the visitor. The following points are a generalization of the actions that take place in the event of a webpage request:
1. Visitor’s browser requests a web page
2. The WordPress core calls the required PHP scripts starting with index.php
3. The WP core then communicates with its database and retrieves the data (posts/pages etc.)
4. It then combines the fetched data, the data from the currently active plugins, and the currently active theme and generates the HTML code “on-the-fly” or “dynamically”
5. It then serves this dynamically generated HTML code to the visitor’s browser
Repeating all these steps every time someone requests a webpage is a time and resource-consuming job. WordPress caching is a solution to this problem. It involves storing frequently accessed data in a cache, which can be quickly retrieved and served to visitors without having to go through all the steps mentioned above. This can significantly improve the performance of your WordPress site, especially during high traffic periods.
WordPress is a powerful CMS that can be used to create a variety of websites. Understanding how WordPress works internally is essential for optimizing its performance and ensuring that your site runs smoothly. In the next part of this series, we will take a closer look at WordPress caching and how it can be used to improve your site’s performance.