WordPress Core Architecture and Request Lifecycle WordPress is a dynamic Content Management System (CMS) powered by PHP and backed by a MySQL or MariaDB database. Understanding the path a request takes from the server to the browser is essential for high-performance development.
1. The Request Pathway When a user accesses a URL on a WordPress site, the following sequence occurs:
Initialization: The index.php file in the root directory loads wp-blog-header.php, which subsequently triggers wp-load.php. Configuration: The wp-config.php file is parsed to establish database connections, set memory limits, and define security constants. Core Loading: WordPress loads the core files in wp-includes/, initializes the plugin environment, and then loads the active theme. The Query: The WP_Query class parses the URL to determine what content is being requested (e.g., a single post, a category archive, or a custom post type). Template Hierarchy: WordPress selects the most specific template file available in the theme (e.g., single-post.php before single.php before index.php) based on the Template Hierarchy. The Loop: The selected template executes “The Loop,” fetching data from the database and rendering the HTML output. 2. File and Directory Structure wp-admin/: Contains the administrative dashboard logic. Core files here should never be modified. wp-includes/: The library folder containing the majority of WordPress core functions, classes (like WP_Query, WP_Error), and APIs. wp-content/: The only directory where developers should actively add files. /plugins/: Individual folders for site functionality. /themes/: Folder for the active design and layout templates. /uploads/: Media and file assets. The Hook System: Actions and Filters The “Hook” system is the mechanism that makes WordPress extensible without modifying core files. This is the foundation of professional plugin and theme development.
...