wp_terms

Published: 3 Mar 2023

The wp_terms table is used to store a WordPress website's categories, tags, and custom taxonomy terms. More details about terms are stored in wp_term_taxonomy and wp_termmeta tables.

Columns

term_id: This column stores the unique identifier for each term in the wp_terms table. Each term, whether it's a category, tag, or custom taxonomy, is assigned a unique term_id (an integer). It is used as a primary key for this table and referenced in wp_term_taxonomy table, which contains taxonomy and hierrarchy (parent/child) information for individual terms.

name: Term name is the human readable "nice" name or title for the term. For example, if the term is a category, the name might be "Recipes". If the term is a tag, the name might be "Healthy Eating". The name value is displayed on the front-end of the website to help visitors navigate and organize content, or as the h1 heading on the category or tag page.

slug: This column stores the URL-friendly "slug" for the term. The slug value is a lowercase version of the name with spaces replaced by hyphens. For example, if the name value is "Healthy Eating", the slug value might be "healthy-eating". The slug is used in the URL when displaying content associated with the term.

term_group: The term_group value is used to sort terms and group them together. For example, if a website has multiple categories for different types of cuisine, you might want to group them together under a "Cuisine" term group. In this case, all categories related to cuisine would have the same term_group value. By default, the term_group value is set to 0, which indicates that the term is not part of a group.

Example

For example, let's say you have a website about healthy eating and you want to organize your content by categories such as "Recipes", "Tips & Tricks", and "Food News".

You create new terms for each of these categories in the wp_terms table. For the "Recipes" category, you might set the name column to "Recipes", the slug column to "recipes", and the term_group column to 0 (since this category is not part of a group).

When you create a new post and assign it to the "Recipes" category, the term_id value for the "Recipes" term would be stored in the wp_term_relationships table along with the post_id of the post. This allows WordPress to query the database and retrieve all posts associated with a particular category.

SQL Schema

CREATE TABLE `wp_terms` (
`term_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`slug` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`term_group` bigint(10) NOT NULL DEFAULT 0,
PRIMARY KEY (`term_id`),
KEY `slug` (`slug`(191)),
KEY `name` (`name`(191))
) 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