wp_term_taxonomy

Published: 3 Mar 2023

The wp_term_taxonomy table is critical for organizing WordPress content. It stores information about categories, tags, and custom taxonomies, in addition to the information stored in wp_terms table. Most importantly, it stores the taxonomy for each term (e.g. "category" or "post_tag"), as well as which term is the parent (for hierrarchical taxonomies, like categories) and number of posts or pages assigned the term.

Columns

term_taxonomy_id: Unique identifier integer ID for each term in this table. It is also used in wp_term_relationships table to identify the term.

term_id: The term_id from wp_terms table, used to link the two tables together. It is often the same number as term_taxonomy_id, but does not have to be (so don't rely on it – they are two different IDs).

taxonomy: The name of the taxonomy, such as "category", "post_tag", or a custom taxonomy, such as "genre" (in a music site) or "destination" (in a travel site).

description: A brief description of the taxonomy.

parent: The ID of the parent term in the taxonomy hierarchy, if any. This allows for hierarchical taxonomies, such as categories, which have subcategories. For example, if a "Music" category has a subcategory "Rock", the parent value for "Rock" would be the term_id of "Music".

count: The number of objects (posts, pages, or custom post types) associated with the term. This value is cached by WordPress and updated whenever an object is associated or disassociated with a term. For example, if there are 10 posts assigned to the "Rock" category, the count value for that term in wp_term_taxonomy would be 10.

SQL Schema

CREATE TABLE `wp_term_taxonomy` (
`term_taxonomy_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`term_id` bigint(20) unsigned NOT NULL DEFAULT 0,
`taxonomy` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`description` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`parent` bigint(20) unsigned NOT NULL DEFAULT 0,
`count` bigint(20) NOT NULL DEFAULT 0,
PRIMARY KEY (`term_taxonomy_id`),
UNIQUE KEY `term_id_taxonomy` (`term_id`,`taxonomy`),
KEY `taxonomy` (`taxonomy`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

By remaining on this website or using its content, you confirm that you have read and agree with the Terms of Use Agreement.

We are not liable for any damages resulting from using this website. Any information may be inaccurate or incomplete. See full Limitation of Liability.

Content may include affiliate links, which means we may earn commission if you buy on the linked website. See full Affiliate and Referral Disclosure.

We use cookies and similar technology to improve user experience and analyze traffic. See full Cookie Policy.

See also Privacy Policy on how we collect and handle user data.

© 2024 WPDir