Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
    </div>
<?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
1  
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? –  boscho May 2 '13 at 6:21
    
Yes that it, sorry for the miss. –  jeromeM May 2 '13 at 6:22
1  
No worries - thanks for the exceptional formatting in your post ;) –  boscho May 2 '13 at 6:29

1 Answer 1

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 ;) –  boscho May 2 '13 at 6:28

Your Answer

 
discard

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.