WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've add the field country in the comment form. Working nice and I can see the value in the table commentmeta.

enter image description here

Now I try to display this value in my comment list.

In my single.php I call the list of comments:

<?php wp_list_comments('type=comment&callback=format_comment'); ?>

In my functions.php I format the comment:

function format_comment() {  ?>
    <div class="comment">
        <p><?php comment_author(); ?></p>
        <p><?php get_comment_meta( $comment->comment_ID, 'country', true ); ?></p>
        <p><?php comment_date('Y/m/d - g:i A'); ?></p>
        <p><?php comment_text(); ?></p>
<?php } ?>

So... to get the value for the meta country I use

<?php get_comment_meta( $comment->comment_ID, 'country', true ); ?>

Without success…

share|improve this question
By "without success," I'm guessing that you mean that your call to get_comment_meta() appears to be returning nothing/NULL/an empty string? – bosco May 2 '13 at 6:21
Yes that it, sorry for the miss. – jeromeM May 2 '13 at 6:22
No worries - thanks for the exceptional formatting in your post ;) – bosco May 2 '13 at 6:29
up vote 2 down vote accepted

Looking at the Codex entry for get_comment_meta(), it appears that when the $single argument is set to TRUE (as you have done), the function returns a string. Try throwing an echo() into the works:

<?php echo get_comment_meta( $comment->comment_ID, 'country', true ); ?>
share|improve this answer
helpfull, thank to show me the way. Now it work with <?php echo get_comment_meta( get_comment_ID(), 'country', true ); ?> – jeromeM May 2 '13 at 6:25
Glad to hear it! Rock on, jeromeM ;) – bosco May 2 '13 at 6:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.