Where Are WordPress Pages Stored in Database? [SQL Lookup]

Have you ever wondered where wordpress pages are stored in the database? WordPress is one of the best CMS in the market, which is developed using PHP and MySQL. It powers over 38% of the websites on the internet with a 63% CMS market share.

Most of the people prefer using WordPress on their websites and if you’ll found millions of website which are just started or the most sophisticated websites hosted on WordPress. Even the website on which you’re currently reading this post (i.e., TheWPX), is also hosted on the WordPress CMS itself. 😉

All the contents of posts and pages stored in a SQL table named “wp_posts“. It is because WordPress is a dynamic CMS build using PHP and MySQL. 

Another best part about using WordPress is, it doesn’t store individual HTML files for each page on your site.

This can be confusing, especially when you’re new to WordPress. When I started my first website with WordPress in 2015, it is hard for me to learn about the ins and out of WordPress and if this is the thing with you, then don’t worry – I’ll try my best to explain everything to you in this article.

So read it till the end to know how WordPress works and where it stores the pages and posts. 

Understanding How WordPress Works

The first thing which you need to make sure is, it is written in PHP and MySQL. This is why it doesn’t store individual HTML pages on your site for every post and page you published on the website.

Instead of this, whenever someone visits the specific page, it loads or fetches the content directly from the SQL and shows it on the frontend side using the PHP.

Everything in WordPress is created dynamically and stored in the database. For example; the header menus, the footer contents, the sidebars, and the posts, everything is stored in the database and access using the PHP scripts dynamically.

Let’s make this simple for you to understand;

  • The visitor request a specific page on your website built on WordPress.
  • WordPress loads the PHP function, starting with index.php.
  • It queries the database and requests the specific post or page your browser requested.
  • WordPress compiles the data along with the plugins and theme and generates an HTML page for it.
  • Then the dynamically generated HTML page sent to your browser for rendering.

This way, WordPress doesn’t have to store any individual page for every page or post on your server, and it uses MySQL to dynamically generate the HTML pages for your visitors.


Where Are WordPress Pages Stored in SQL?

So where the pages you created stored in WordPress? 

As we told you above, WordPress stores content or the pages you created in the database. All the pages you created on your website are stored in a table named “wp_posts“. 

If you wanted to modify the file manually or to replace words using the SQL, then either you can use MySQL commands through SSH, or use tools like phpMyAdmin to access the SQL database of your server. It is a powerful tool that is used for managing the database and the files inside it.

Most probably, you’ll find the phpMyAdmin on the control panel provided by your hosting provider. In my case, I’m using cPanel, so I’ve to log in to my cPanel account and then search for the phpMyAdmin in the database section as shown in the image below.

phpmyadmin in cpanel
phpMyAdmin in cPanel

Once you click on the “phpMyAdmin“, it will redirect you to the dashboard from where you can manage the database and modify it according to your needs.

I don’t recommend making any changes through the “phpMyAdmin” dashboard, especially when you’re not aware of it. It can be harmful if anything goes run and you’ll lose access to your website and it can’t be undone in any way.

find the table named "wp_posts" in sql
Find the table named “wp_posts” in SQL

When you click on the database used by your WordPress website, it shows the table inside of the database which is being used by your website. In WordPress, the default number of tables is 12, which can be increased depends upon the theme or the plugin you’re using on your website.

Here you’ll also find the table named “wp_posts“, which stores the content of posts, pages, and custom post types. As the table name is “wp_posts“, I know you must be thinking about how it stores different data of pages and other custom elements. nah?

column named "post_type" inside "wp_posts" in wordpress
Column named “post_type” inside “wp_posts” in WordPress

Well, inside the “wp_posts“, you’ll find a column named “post_type” which includes all post types (post, page, custom post, etc) used by WordPress, its themes, and plugins. This field specifies whether the content stored is a page, post, or a custom post.

And on the other columns, you’re seeing in the image above, WordPress stores different types of metadata in each specified column from the author’s name to total comment counts.

That’s it! This is how WordPress uses SQL to store pages and other important things.


How to Backup SQL Database of WordPress

It’s simple to backup the database of your WordPress. You can either do it from the phpMyAdmin or by using any WordPress backup plugins like Updraft and All in One Migration.

Here I’m sharing the steps below through which you can easily take the backup of your database using the phpMyAdmin. 

For exporting database using phpMyAdmin, first, you’ve to log in to the control panel or the cPanel of your server and then click on the phpMyAdmin option. It will redirect you to the database page, where it shows all your databases.

Click on the database you want to take backup. In this case, I’m backing up the “thewpx_wpx” named database, where I’ve stored the database of my dummy site for writing this article.

exporting database using phpmyadmin
Exporting Database Using phpMyAdmin

Once you’re inside your database, click on the ‘Export” option showing above your database files. It will open the export page, from where you can download the backup of your WordPress server easily.

exporting database of dummy website
Exporting Database of Dummy Website

Once you’re inside it, it will show two methods to export your database and the format in which you want your database files to be.

Here I’ve selected the “Quick” method for exporting my database for minimal options and to include everything in my database and also selected the “SQL” file format which is efficient to store SQL database.

Now click on the “Go” button showing after the format options and it will start downloading the database to your local system.


Important Files in WordPress & Directory Structure

There are a few more important files you find in WordPress and yes, they’re not limited just to the database. These are the important files through which your website runs flawlessly. These files can include the plugin files you stored on your website, or the theme you’ve activated on your website.

Here I’ll tell you more about the files and directory structure of WordPress. It will really help you to understand more about WordPress and how it works.

So when you log in to the control panel or the cPanel of your website, then click on the “File Manager” option. It will redirect you to the file system of your website. 

Here you’ve to double click on the “public_html” folder and it will redirect you inside of the folder where all your WordPress files are stored as shown in the image below.

files & structure of wordpress
Files & Structure of WordPress

These are the important files that are used by WordPress CMS to work properly. Inside of the “wp-content” folder, you’ll find other folders named “uploads“, “themes“, and the “plugins“. Here WordPress stores all the media you upload on your website, the theme you’re using on your website, and the plugins.

Apart from this, you can also find a few more folders depends upon the plugins which you’re using. The “wp-content” and the “wp-config.php” files showing in the image above are the most important files and folders in WordPress through which your website functions properly.

But always keep in mind to never delete any of these files or folder which are shown in the image above, a small change or if you remove any file or folder here can harm the website and make it completely inaccessible.

Wrapping Up!

In summary, wordpress pages are stored in your database in a table named “wp_posts” and all other wordpress templates and plugins files are stored in the “wp-content” folder with themes and plugin names, respectively. 

Generally, there is no need to edit the pages manually from the database or the system files of WordPress from the file manager unless you know what you’re doing. 

However, if you need to edit or customize anything, you can customize the theme from the theme customizer option and edit the WordPress pages using Gutenberg Editor, Classic Editor, or using a WordPress page builder.

That’s enough for today. I hope you loved this article and if you do, please share this article with your friends, family, and with your followers. If you still have any doubts about WordPress or their database and file structure, you can leave your comment in the comment section below.

Sunny Kumar

Number of posts: 154

Hi, I'm Sunny Kumar, a passionate tech enthusiast and a blogger from New Delhi, India. With a degree in IT from IIT-D and expertise in SEO, Cloud Computing, Telecom & Networking, and CEH, I specialize in various technical fields, including SEO, WordPress Development, and PC Building. And being a proficient WordPress user, I’m dedicated to delivering quality content and a remarkable user experience.

Leave a Comment