Read post meta
wp_get_post_metaRead one post's custom fields by key or retrieve all public keys, with protected and credential-like keys excluded. Use it to inspect post meta values directly.
Instructions
Read custom fields (post meta) of one post: one key, or all public keys. Keys starting with "_", keys WordPress marks as protected and credential-like keys are not available, and keys are returned only where the account may edit the post (and the key). Returns {id, key, value} (with several stored values, the first) or {id, meta: {key: value}} (a key with several values gives a list). An unknown post id returns a not-found error. Read-only. wp_get_post returns the same keys along with the post; page builder layouts are read with wp_get_builder_layout, SEO fields with wp_seo_get.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Post id. | |
| key | No | One meta key to read. When omitted, all public keys are read. A key the post does not have returns an empty value, or the default a plugin registered for it. |