Reputation: 2486
I have 2 custom fields in my post named Status and Version. I would like to retrieve the value of the field Status to display within the post. According to the documentation the following should retrieve the value.
<?php get_post_meta($post->ID, 'Status', true); ?>
However nothing is returned.
Doing the following
<?php the_meta(); ?>
Returns the names and values of all the custom fields, so they appear to be added correctly and working. Am I doing something wrong, or does anyone have any ideas?
Upvotes: 0
Views: 63
Reputation: 7611
When you say "nothing is returned", what are you expecting
<?php get_post_meta($post->ID, 'Status', true); ?>
to do? get_post_meta
just returns the value, it doesn't echo it, and you're not storing it in a variable. Does adding echo
, like this:
<?php echo get_post_meta($post->ID, 'Status', true); ?>
do what you're after?
Upvotes: 3