Where is Taxonomy and Terms Data in the WordPress Database?

When you add a Tag or Category to WordPress posts, it is stored in your WordPress database. This makes it possible to WordPress to easily connect terms to your posts.

In this guide, we’ll show you where and how WordPress stores your term data. Our team also wrote a similar guide for finding Media Library data.


Understanding the Terms Data

If you want to understand the relationship between posts, terms, and taxonomies, I recommend installing the Reveal IDs plugin. This will show you the database ID numbers for key items on your site. On the screenshot below, you can see the “Tags” screen in a WordPress site. Normally, the “Tags” screen will show the first four items, but the “Reveal IDs” plugin has also added the “ID” column.

  • Name
  • Description
  • Slug
  • Count
  • ID
An example of the Tags screen in WordPress

This next screenshot shows the “Posts” area. Again, you can see the “ID” column which is not normally displayed in WordPress.

WordPress posts with the ID

Where is the Term Data in the WordPress database?

WordPress uses four key tables to organize your term data:

  • _terms
  • _term_relationships
  • _term_taxonomy
  • _termmeta
Term Data in the WordPress database

About a decade ago, Brad Williams posted this visual guide that explained how three of the key database tables are related. The _termmeta table is a more recent addition.

Term database tables

The _terms table

This screenshot below shows the _terms table. It contains three items that we saw on the “Tags” screenshot above:

  • term_id (this is the “ID” column in the screenshot)
  • name (this is the “Name” column in the screenshot)
  • slug (this is the “Slug” column in the screenshot)
The _terms table in WordPress

The _term_relationships table

This next screenshot shows the _term_relationships table. This table links your posts to your terms.

  • object_id (This is the ID of the post)
  • term_taxonomy_id (This is the ID of the term)

So in this table you can see six terms connected to one post. You’ll notice that WordPress does not care about the taxonomy at all. There is no difference between how Categories and Tags are listed in the database.

  • 1:1 (This links the post with an ID of “1” to the term with an ID of “1”)
  • 1:2 (This links the post with an ID of “1” to the term with an ID of “2”)
The _term_relationships table in WordPress

The _term_taxonomy table

This screenshot below shows the _term_taxonomy table. This table contains extra information about the terms that we haven’t seen in earlier tables:

  • taxonomy
  • description
  • parent (this is for terms arranged in a hierarchy)
  • count
The _term_taxonomy table in WordPress

The _termmeta table

The final table is _termmeta. This is not used by the WordPress core, but it can be used by plugins to add more data to taxonomy terms.

One straightforward example is the “WP Term Images” plugin. This plugin adds an “Image” field to your taxonomy terms, as you can see in this screenshot:

A plugin that creates term meta

That extra metadata will now show up in the _termmeta table:

Metadata in the _termmeta table

Leave a Reply

Your email address will not be published. Required fields are marked *