Where Are WordPress Pages And Posts Stored? The WordPress Database

by Author
Where are WordPress Pages and Posts Stored

It is important to have reliable storage for all posts and pages on your WordPress platform, this can help you retrieve these contents especially when an accident happens and your hardware crashes. The hosting cPanel is usually a platform where you can access your content at any time.

So, Where in WordPress are Posts and pages stored?

Your WordPress posts and pages are normally stored in the WordPress database.

The WordPress database does not only store your pages and posts, every other component including attachments, comments, and images on your posts and pages will be stored under different categories. Posts and pages and other components of your WordPress site are not only stored for safety purposes but can also be stored for future references. For instance, you might be searching for a new topic to write and you may check from the database to ensure you don’t write duplicate topics.

What Are The Contents Of WordPress Stored In The Database?

Generally, your posts and pages are stored in the database of WordPress. These contents also include custom posts such as posts of products you sell if you run a commerce store. All data about your attachments are also stored here, these include information on attached images, videos, and so on.

All metadata including post tags and categories alongside custom taxonomies, if you have them on your WordPress site. Also, custom fields, as well as all metadata that are added through plugins, are also added to the WordPress database. Any information on the attachments you add to your website including the names of files alongside metadata such as “Alt texts” and descriptions are stored in the database. Similarly, information on which pages or posts might have been attached is also stored in the WordPress database.

All your website settings, including your overall or general site settings such as site titles and descriptions plus the specific settings for the plugins and themes, are stored in the database.

There are 12 tables located in the WordPress database where your posts and pages are stored. These tables represent the WordPress Codex.

Wp_post is the table in the WordPress database where the contents of your posts and pages are stored. This is also the table where information and attachments are stored. Your website’s navigation menu and revisions are also stored here.

The Wp_postmeta is the table where metadata about your posts and pages are stored. This table is also linked to the Wp_post table. Wp_comments is the table in the database that stores all comments on your website posts, alongside those that made the comment and when the comments were posted. This table is linked to wp_users.

The wp_commentmeta is the table that stores all the metadata about posts’ comments, and it is linked to wp_comments. The wp_terms is responsible for keeping all taxonomy-related terms on your website, these include a taxonomy of categories and tags. This table is linked to wp_terms and wp_terms_relationships.

The wp_term_relationships table will link your posts to the taxonomy terms that have already been assigned to them. The Wp_termmeta table will store the metadata on your taxonomy terms. Wp_users is the table that stores the lists of users on your website as well as their username, passwords, and other relevant information. Wp_usermeta stores all metadata on your website users and it is linked to wp_users.

For any given post, WordPress can quickly determine what Taxonomy terms are attached, which means the writer, comments on the posts, and other uniqueness of the posts are automatically recognized.

There are two other tables that have no relationship to your posts, these are; wp_options and wp_links. Wp_options is the table where the global options and settings for your website are stored. Wp_links can be described as a hangover in the early days of blogging and it is the one that stores a list of links that are rarely used these days.

The Workings Of WordPress Through Database And Files

WordPress can be described as a Content Management System software (CMS). This means that instead of having a static HTML file, on all your files, you will have a database to store all your contents of your content. The database will use code to access the content on the posts you create each time.

In addition to the database, WordPress comprises two more elements; the core files, and Media attachment uploads. The core files are those that run the WordPress itself, and these are the core files you installed when you set up your WordPress site. The second element comprises any file you have uploaded on your site and these include plugin and theme files alongside your media attachments.

WordPress will use these elements to build your website without you having to build any code.

How Does WordPress Gather Contents From Your Pages?

WordPress is able to gather content from your website with the help of a code, referred to as the “loop”. The Loop with gather contents and attach different code to them based on their location on your website.

The loop code will begin work with the following code; <?php if ( have _posts() ) : while ( have_posts() ) : the_post(); ?>. This code will check whether there is new content to be outputted on a page and if there are any, the code will use the Wp_post   template tag so that the newly discovered post will become outputted.

Keep in mind that the “post” in this code doesn’t refer to the blog post. The post in the code could be any type of content and these could be a regular blog post, attachment, page, and a custom post. The loop often end with a code which is; <?php endwhile; endif;?>. With this end code of the loop, WordPress will stop checking if there is any new post on your site.

In-between the checking of posts and ending the check is another code that will output the content. WordPress will always detect what content is relevant for the current page it is working on based on the type of page you are visiting. For instance, if it is an archive page, WordPress will know whether it is a category archive or another type of archive.

For a single post or page, WordPress will use this code to show which is being output. It does this by using the correct template file from “Theme” and using the theme’s hierarchy, it will output the relevant loop for the current content type.

For the Homepage, for instance, the way your home page is displayed will depend on how you have already set it up. This means that the home page could be a list of your most recent posts or a static page. Both static and dynamic homepage design have their merits. You can change the configuration of your Home page from the menu of your settings in the WordPress Admin.

If for instance, your home page is static, it will normally use the same static template file as any other static page on your WordPress site and the same loop version. This should be the case unless you have chosen another theme for your home page template. For instance, a template may be used to create a home page and also add a slider for some customized effects. Either one you choose, the loop should be similar to the single page loop code above. If your home page is just an archive of your old posts, it wouldn’t use the archive. Php template, instead it will use the index. Php file which is regarded as the “catch-all template file”, is used for all pages that do not have a specific template file.

When the loop is fetching new posts and outputting them, you will see an excerpt or a brief of the content being outputted. This also will depend on the code inside the loop. Whichever way your home page is designed, it will constantly use the loop to access the database and retrieve the static page or a number of posts you posted recently.

Fortunately, experienced programmers do know how to change codes in loops to provide even more customized output on their websites.


The power of WordPress comes from the fact that it is a Content Management System (CMS). This means that, for you to create a website, you don’t need to be a professional programmer to write codes. Instead of creating codes, you create posts and pages in the WordPress admin and the WordPress will save every new content into its database and before they are outputted into their relevant pages on your site where people can access them.

With this arrangement, WordPress will make it easier for you to create and manage your site. There are a number of tools and resources you can also use in expanding and grow the site. You can always refer to the WordPress development learning guide if you are unsure of handling any aspect of your site.

Related Posts