What is post metadata
Post metadata is data that’s saved in the wp_postmeta table in the database. Each entry is saved as four fields in this table:
- meta_id: A unique ID for this specific metadata.
- post_id: The post ID this metadata is attached to.
- meta_key: A key used to identify the data
- meta_value: The value of the metadata.
In the following screenshot, we can see how this looks in the database.
Metadata is just key/value pairs saved for a specific post. This allows us to add all sorts of custom data to our posts. It is especially useful when we are developing custom post types.
Following function are used to add/edit/delete/select meta data.
- add_post_meta(): Adds post metadata.
- update_post_meta(): Updates post metadata.
- delete_post_meta(): Deletes post metadata.
- get_post_meta(): Retrieves post metadata.
No comments:
Post a Comment