Where are post and pages stored in WordPress?

Wordpress pages and posts in database

WordPress stores all data of your posts, pages and custom post types (like projects) in its MySQL/MariaDB database. For technical reasons the data is spread over multiple tables, but the main content is located in the wp_posts table. In this article we will show you how to find the locations where the posts and pages are stored in WordPress and show you how to export them easily in a human readable way.

Get access to your WordPress database

First, you must get access to the database of your WordPress website. To do this, go to the customer center or the web interface of your web hosting. There you should find a “Database” section where you can find all databases created for your website. Almost all web hosts allow you to open your database in a viewer web application like phpMyAdmin, which should be linked there. If this is not the case, please check the knowledge base of your web host or contact the support of your web host to find out how to access your database.

Some webhosters do not allow you to automatically log into your database via phpMyAdmin. If you do not know the credentials, follow these steps:

  1. Open your FTP client and connect to your webspace.
  2. Go to the root directory of your WordPress system, where you find all WordPress related files.
  3. You find a wp-config.php file here. Open this file in any text editor you have installed on your computer.
  4. In the rows with the keywords DB_USER and DB_PASSWORD, you find the username and password to access your database in phpMyAdmin.
wp-config.php opened in a text editor
wp-config.php opened in a text editor
wp_options table opened in phpMyAdmin
wp_options table opened in phpMyAdmin

Find the location where posts and pages are stored

We are in phpMyAdmin or a similar tool and see all tables of our WordPress database. Each table contains different types of data. Below you will find an explanation for all relevant tables related to the article and the page content. Please note that if you use a plugin or theme, it can store additional data related to your content (e.g. embedded galleries) in its own tables. Furthermore, the names of your tables do not have to start with wp_, but can start with a different prefix:

  • wp_posts: The content of your posts, pages and other post types. This includes the author, creation date, modification date, text content, title, excerpt and publishing status.
  • wp_postmeta: All metadata that refers to any kind of post in wp_posts. For example, the displayed image, the editing lock (who is currently editing the post), or custom fields.
  • wp_term_relationships: Posts and other types of contributions can be assigned to categories, which are technically called “terms”. The table contains the assignment of posts to categories.

Export posts and pages from WordPress easily

In the previous section we have seen a more technical perspective, where exactly the posts and pages are stored in your WordPress. You now know that the content is stored in the database and folders and files in the file system, as for example for this blog post /2020/where-are-post-and-pages-stored-in-wordpress/, does not exist, but it is automatically generated when you open the blog post.

Maybe you want to know where the articles and pages of your WordPress site are stored so that you can export them? If this is the case and you only want to export the content, but not the rendered HTML, it’s pretty simple:

  1. Open your WordPress backend and go to Tools > Export .
  2. Select the content you want to export and click the Download Export File button.
  3. All of your selected content will be exported and you will download it as an XML file (uploads like images are only linked, but not downloaded part of the export).

Is the database slow because of too much content? Optimize it!

As a blog or website gets older, many posts and pages are stored in these tables. Including all revisions to all content you have ever created. This can slow down your entire website and finding the content in the WordPress backend can be quite annoying.

You can change this and get your WordPress database back up to speed. Our friends from wpDataTables have written an article about how you can speed up your WordPress database. Check out the article!