0

I'm sure this must be a silly error by me but I haven't been able to solve it...

I added an extra 'rating' field to my comments form so that users can rate posts. Everything works fine and by using add_comment_meta( $comment_id, 'rating', $rating ) it gets inserted fine in the wp_commentmeta table.

However, when I try to retrieve the value using get_comment_meta( comment_ID(), 'rating', true ) I'm getting the comment ID instead of the rating value.

Any ideas on what could be wrong? Thanks in advance...

FIXED:

comment_ID() echoes the ID. What I needed was get_comment_meta( get_comment_ID(), 'rating', true )

  • Please, post the answer in the answer section. – cybmeta Jan 9 '15 at 7:25
1

Actually this is what you need to use.

<?php echo get_comment_meta( $comment->comment_ID, 'rating', $rating ); ?>

IDs are already stored in $comment array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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