The wp_postmeta
table is used to store additional information related to posts, such as custom fields or post thumbnails. It is often used by plugins or themes.
Its structure is similar to the other meta tables (wp_commentmeta
, wp_termmeta
, wp_usermeta
).
Columns
meta_id
: Auto incrementing integer ID, used as primary key. It has no other meaning.
post_id
: ID
of the post the meta belongs to (the ID
column from wp_posts
table).
meta_key
: Key of the meta data. This column is used to uniquely identify the meta data. Examples: "_thumbnail_id" or "meta_description".
meta_value
: Value of the meta data, stored as serialized string. Example: "123" for the "_thumbnail_id" meta key.
SQL Schema
CREATE TABLE `wp_postmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_id` bigint(20) unsigned NOT NULL DEFAULT 0,
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`meta_id`),
KEY `post_id` (`post_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;