Codex tools: Log in / create account
Contents |
This function returns the values of the custom fields with the specified key from the specified post. See also update_post_meta(), delete_post_meta() and add_post_meta().
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>
<?php $key_1_values = get_post_meta(76, 'key_1'); ?>
To retrieve only the first value of a given key:
<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>
For a more detailed example, go to the post_meta Functions Examples page.
The function returns an empty string if the key has not yet been set, regardless of the value of $single.
update_post_meta(), delete_post_meta(), add_post_meta(), get_post_custom(), get_post_custom_values(), get_post_custom_keys()