Uso

<?php $meta_values = get_post_meta($post_id, $key, $single); ?>

Parametros

$post_id
(integer) (required) The ID of the post from which you want the data. Use $post->ID to get a post’s ID.
Default: None
$key
(string) (required) A string containing the name of the meta value you want.
Default: None
$single
(boolean) (optional) If set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields. This is not intuitive. For example, if you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string.
Default: false

Ejemplo 1

<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>

Ejemplo 2

<?php if ( get_post_meta($post->ID, 'thumb', true) ) : ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">
        <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />
    </a>
<?php endif; ?>

Leave a Reply