In 2023, WordPress powers more than 35% of the internet, which increases 2% compared to early 2019, and the numbers are growing day by day. Stable performance, fast loading speed, security, and easy to use interface is the reason behind it.
If you have recently started using WordPress, you may wonder where WordPress stores posts and pages? You’re mistaken if you think WordPress creates and stores individual HTML files for each post and page you publish.
Now the question arises if WordPress did not create different files for each post and page, then how would the complete system work, where WordPress stores posts and pages?
When requested, the WordPress code recalls the data from a database table to display. Now, after hearing the word “Database,” you may be confused. Don’t worry, below I have explained everything you need to know. Read the post carefully.
Understanding How WordPress Works
First, it is essential to clarify that WordPress is written in PHP, not as HTML, and it uses MySQL for the database. WordPress does not store a single page or post as an HTML document. When you publish any new post or page, it just adds an entry to a database table.
When someone opens the website, the browser requests the server for the files, WordPress PHP scripts gather the data from the MySQL database and present content in front of the visitor.
Not just posts or pages, everything in WordPress is created dynamically and stored in the database, including the header menus, the footer contents, the sidebars, and the posts.
Here is how everything works in simple words;
- The visitor who is known as the client enters the website address in the browser then the browser requests the server for the files using DNS.
- When WordPress PHP scripts get requested, it starts loading the files beginning with index.php.
- It recalls the browser-requested data from the database.
- Then the WordPress PHP scripts work together and compile the data with plugins and themes to generate the HTML page.
- The page will be generated dynamically and sent to the browser for rendering.
This is how the complete system works. They store no files in HTML and all files are generated automatically using PHP after getting data from the database.
Where Are WordPress Posts Stored in SQL?
Now you may question if everything is stored in a database, where precisely the posts are stored. The answer is that all the posts are stored in the table named “wp_posts. ”
It is also possible to modify the posts manually by editing the database. You can edit your website’s SQL database with the help of an SSH command or the tools like PHPMyAdmin. PHPMyAdmin is one of the most used, easy-to-use tools that allow you to manage the database and the files inside it entirely.
You can easily open PHPMyAdmin from the control panel of your hosting. If your website is hosted on VPS, then you have to check whether the PHPMyAdmin is installed on your server or not. In my case, my website is hosted with cPanel.
First of all, login to your Webhosting account (cPanel) and search for PHPMyAdmin. You will get it in the database section, as shown in the image.
Click on PHPMyAdmin., you will be redirected to its dashboard. From here, you can manage your database entirely, modify it according to your needs.
You will see all the databases in PHPMyAdmin. First, you have to rectify that which is the database of the particular website you want to make changes to. If there is a single website hosted, then you don’t have to worry about it.
Click on the database to open. It will start showing you the tables on the right side. Generally, there are 12 tables, but the number can be increased depending upon which theme or plugins you are using.
Here you will get the table named “wp_posts,” which stores all the content of posts, pages, and custom post types. The table is called “wp_posts,” but it also stores pages and custom post types.
Well, you will get the column named as “post_type” in the “wp_posts “database table, which includes all the post types such as post, page, custom post. The field specifies that the content is a page, post, or a custom post.
All the other tables and columns in the database store different types of information like author name, total comment counts, and social share information if you are using any plugin. That’s how the complete system works.
How To Backup SQL Database of WordPress?
It is imperative to take the backup of the entire database if you are going to make any changes. And even if you are changing the host, you can backup the SQL database from your current host and restore it to a new one.
You can back up a database in two different ways. First, by using the WordPress backup plugin like Updraft and All in One Migration. And you can also take the backup manually from the server-side.
You are reading this article that means most probably, you are going to edit the database manually. That’s why below, I have shared the manual way to backup the database. It is also the easiest way to backup.
To backup the database, you need to login into your Cpanel, then find and click on the PHPMyAdmin option, you will get it in the database section. It will redirect you to the PHPMyAdmin control panel.
On the left side, you will see the list of all the available databases and click on the one you want to backup. Here is my case, I am going to back up the “thewpx_wpx” named database.
Now the database will open in front of you. On the top, you will get the option as Export, click on it. From the export option, you can export your database in one click.
Choose the desired option. I highly recommend choosing the “Quick” method as it backups the entire database and selects SQL as the file format. SQL format is the most efficient format to store the database. Click on Go, the downloading of that database will start.
Important Files in WordPress & Directory Structure
WordPress is not just about the database, there are a few more essential files responsible for running your website flawlessly. Those files contain all the settings, the plugin you are using on your website, and the theme you have activated.
Here I’m sharing more information about the files and directory structure of WordPress. This information will help you understand how WordPress works.
To see those files, log in to your hosting control panel, here I am using cPanel. Go to the File Manager option, and you will be redirected to your website’s file system.
Click on the folder where you have installed WordPress for a particular website. It is a “public_html” folder if there is only one website hosted on your server. This folder contains all the website files.
All those files are essential to run your website. In the “wp-content” folder, there are 3 subfolders named “uploads “, “themes “, and the “plugins” in which all the data of your plugin, theme, and the media you have uploaded is stored.
You will also see a few more folders here depending upon the plugin which you’re using. The files named “wp-content” and the “wp-config.php” are the web site’s most important files. Those two files are responsible for all the functions.
It is highly recommended not to edit or delete any of those files or folders. Any change may break your website.
I hope you get what you are looking for. WordPress pages are stored in the database, not as HTML files. WordPress PHP scripts recall the data from the database and present it by generating the HTML file when requested by the visitor.
If you are just a normal WordPress user, then there is no need to open and customize the database in any condition. You can do all the customization from the WordPress admin dashboard itself. Even now, you can present your content more engagingly with the help of the new Gutenberg Editor.
Gutenberg Editor is the new drag and drops editor by WordPress. It allows you to customize the page as you want fully, works like visual page builders Elementor.
Please do share this article with your friends and family if it is helpful for you in any manner. If you still have any questions, you are free to ask in the comment section below.