Have you ever wondered where WordPress stores posts and pages? It’s a bit counterintuitive, especially if you’re not familiar with how WordPress works.

WordPress stores the content of your posts and pages in the wp_posts table of your database. Because WordPress uses dynamic PHP templates to display your content, it does not store an individual HTML file for each page on your site.

Again, this may be confusing if you’re just starting to learn the ins and outs of WordPress. Don’t worry—in this article, you’ll learn exactly how WordPress stores your posts and pages and displays them on your site.

Understanding How WordPress Works

The first thing to understand about how WordPress stores posts and pages is that WordPress is written in PHP, not HTML.

Every time you visit a WordPress site, it loads a set of PHP scripts that query the database for the required content, and it uses that content to build out an HTML page on the fly, before sending that page to your browser.

This allows WordPress to compile dynamic content from multiple sources—your header, your sidebar, your page content, and your footer, for example—into one cohesive page.

To simplify things, here’s what happens when someone visits your WordPress site:

  1. The visitor’s browser requests a specific page
  2. WordPress loads the necessary PHP scrips, starting with index.php
  3. WordPress queries the database and retrieves the data for the requested post or page
  4. WordPress compiles the page/post data with the data from your active plugins and theme and generates an HTML web page
  5. That dynamically-generated HTML page is sent to the visitor’s browser

This happens with every page on a WordPress site. It’s all generated dynamically, so you won’t find your HTML page content in your file system.

Where WordPress Stores Posts And Pages In The Database

WordPress stores the content of your posts and pages in the wp_posts table of your database.

If you want to view or modify this data, you’ll need to use a tool like phpMyAdmin. On most web hosts, you can do this by logging into cPanel (or your host’s control panel) and locating the phpMyAdmin icon:

Note: You should not attempt to edit your database unless you know what you’re doing. In the vast majority of cases, there is no reason to edit your page/post data outside of the WordPress dashboard.

After opening phpMyAdmin, you’ll want to select the name of your database in the left sidebar:

If you installed WordPress with an autoinstaller, this will probably look something like account_wp20. Look for the “wp” for WordPress.

After selecting your database, you’ll see a list of database tables:

Click on the one titled wp_posts.

You’ll then see a list of content items on your WordPress site, from attachments to posts, pages, revisions, and more:

Each column in the table contains a certain type of metadata for each item. For example, there are columns for the post title, post content, excerpt, post status, comment status, and so on.

Most likely, this table contains a LOT of stuff that you’re not looking for. If you’re looking for a specific type of content, e.g. posts or pages, you can sort the table by the post_type column. You can also use the search bar to search for the word “page,” for example.

There it is! This is where WordPress stores your posts and pages.

From here, you can easily edit any of the items to manage the content or metadata of a given post or page as needed.

Backing Up Your Database

Keeping regular backups is a key component of good WordPress security. Before making changes to your WordPress database, you should always create a backup.

Ideally, you’ll have an automatic backup solution in place for your entire site, but you can also export a copy of the database directly through phpMyAdmin.

You can do this by clicking the “Export” tab at the top:

From here, simply follow the prompts to download a .sql export file of your database.

In the event that something goes wrong, you can restore your backup later using the “Import” tab.

Where To Find Your Theme’s Page And Post Templates

WordPress stores the content and metadata of your posts and pages in the database, and that data is dynamically merged into your current theme’s PHP templates, which you can find in your file system.

You can use an FTP client like FileZilla or your cPanel file manager to access your site files.

New to FTP? Check out our full WordPress FTP tutorial here. 👈

From your site’s root directory, navigate to /wp-content/themes/your-theme/, replacing your-theme with your currently active theme.

Within this directory, single.php is your single post template, while page.php is your page template.

If you know what you’re doing, you can edit these files to change the way WordPress formats your content. (It’s a good idea to use a child theme to ensure your changes aren’t overwritten by a future theme update.)

Keep in mind that these files do not contain the content of your individual posts or pages—they simply format the web pages, query the database, and tell WordPress how and where the content should be displayed.

Final Thoughts

In summary, the content of your posts and pages are stored in the wp_posts table of your database, while your post and page templates are stored in your file system at /wp-content/themes/your-theme/.

There’s generally no reason to edit your posts and pages from the database, as the WordPress dashboard handles this quite well. However, if you’re having trouble editing some particular metadata in the WordPress admin area, going directly to the database can be a surefire fix.

If you have any questions about your WordPress database or file structure, please feel free to leave a comment below!

  • this helped me recover the content of my posts from an old site!!! A+

  • Avatar rob says:

    So what is the internals of switching from Plain permalink to Post name permalink. I have tried all kinds of suggestions but I still get 404 when I set permalinks to Post name. I want to understand how this works, and why wordpress needs the rewrite model?

  • Avatar confirmbiz says:

    thank you so much for this article, I used the knowledge to track down the problem with my site for 2 days now. Thanks, confirmbiz.com

  • Avatar lderonde says:

    Thank you so much for disclosing this information is such a clear fashion. I really appreciate it!