When creating custom page templates, how do I get the value of a custom field of the displayed page?
Tell me more
×
WordPress Answers is a question and answer site for
WordPress developers and administrators. It's 100% free, no registration required.
|
Use the get_post_meta function. |
|||
|
|
WordPress Custom FieldsWordPress custom fields contain a key and a value. To get both
To return a value stored for a specific key use:
If a post contained more than 1 value for the same key you can use a foreach loop to output all of them i an array:
This will return:
To return an array of keys within all custom fields use:
Adding custom fields to a post:
|
|||
|
|
