WordPress stores pages and posts in a database, and not in files in the file system like standard html/php sites do.
This means that the way it reacts to a web page request is very different to a standard HTML website.
In this tutorial we look behind the scenes at what happens when you request a page from a WordPress website and how WordPress displays web pages.
We will start first by looking at a standard website and then compare that with WordPress.
Standard HTML Website
When you request a file on a standard website that uses just HTML web pages the web server simply retrieves the file (web page) from the file system and sends it to you.
The name of the file is part of the url that you type into the browser.
In the screen shot below the web page being requested is starting-html.htm and you can see from the screen shot that the file physically exists on the web server.
Standard PHP Website
When you request a php file on a web server then the server must read the file, and pass it to a PHP processor.
The PHP processor interprets the PHP code, and sends the result to the user’s browser as HTML.
In the screen shot below the page being requested is called Page1.php and again it exists on the web server.
In both of the above cases a physical file exists in the directory of the website.
Although WordPress is a PHP application, and uses PHP files the actual user content is stored in a Database.
When you request a file from a WordPress website the physical file doesn’t actually exist , but it is created dynamically.
So a request for the web page http://www.site.com/webpage.htm on a standard website retrieves a physical file.
A request for the web page http://www.site.com/webpage on a WordPress website retrieves a page from a database.
Note: WordPress doesn’t use file extensions like you find on normal websites.
The url that the user types into his web browser is converted by WordPress into a database query.
The database query retrieves the requested web page from the database.
Because a database query is used, it is possible to create web pages from multiple WordPress pages or posts.
In fact a standard WordPress blog will display the last 10 blog posts on the home page.
The WordPress Index.php File
The entry point to a WordPress website is via the index.php file which is in the root of your website.
This may not seem very obvious as you never actually access this file directly.
Index.php is used because it is set as the default home page on the web server.
This video shows how home pages work.
All web page requests are passed to the index.php file by the .htaccess file entry.
The index.php starts the WordPress Load Process.
Related Articles and Resources:
- Beginners Guide to the WordPress Loop
- Understanding The WordPress Query
- Beginners Guide to WordPress Templates
- Understanding WordPress Shortcodes
- WordPress Functions and the functions.php File