Skip to main content

Post meta is a data set containing additional core as well as custom post information.

The post meta data gets saved inside its own table named {$wpdb->prefix}_postmeta. It contains the following columns:

│ post_id  │ meta_id  │  meta_key  │meta_value│
│ 1233456  │ 1234456  │     foo    │   bar    │
│bigint(20)│bigint(20)│varchar(255)│ longtext │

The post_id is needed to do JOINs, so the {$wpdb->prefix}_posts table can connect to this table.

The data that gets saved here by core:

  • _edit_lock
  • _edit_last
  • _thumbnail_id

This table also saves the data entered in custom fields.

And it's as well meant to hold additional custom data. If you want to search by custom field with a meta_query, it's better to use a single entry per value. Else you save it as serialized array (which core will do on it's own).