Title: Return multiple comment_meta keys
Last modified: August 22, 2016

---

# Return multiple comment_meta keys

 *  [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/return-multiple-comment_meta-keys/)
 * I’ve this code
 *     ```
       $args = array(
                       'post_id' => $post_id,
                       'meta_query' => array(
                                               'relation' => 'AND',
                                               array(
                                                   'key' => 'review_title'
                                               ),
                                               array(
                                                   'key' => 'review_rating',
                                               )
                                           ),
                   );
   
       $comments_query = new WP_Comment_Query;
       $comments_array = $comments_query->query( $args );
       ```
   
 * It works fine, will work only if review_title AND review_rating exists. But it
   return only the second key, and I need to return both. How can I do that?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/return-multiple-comment_meta-keys/#post-5860770)
 * You must be referring to what your template or walker is displaying? WP_Comment_Query
   only returns comment objects, no meta values at all. It’s up to your theme’s 
   template or walker function to get any desired meta values based on the current
   comment object’s ID, then output said values to the browser or concatenate to
   a returned string.
 * The short answer is you need to edit your theme’s comment template or walker 
   function, depending how your theme displays comments.
 *  Thread Starter [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/return-multiple-comment_meta-keys/#post-5860778)
 * Hi bcworkz,
    you’re right, according to the doc WP_Comment_Query shouldn’t return
   meta values at all. But if I do a print_r ($comments_array) it return 1 meta 
   value (the second one if I use and, the first if I use or). Simply don’t know
   why.
 * Just to be safe I’ll get the needed meta value using the comment id
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/return-multiple-comment_meta-keys/#post-5860783)
 * That’s what I would do. The last used value sounds like a quirk similar to where
   the final value in a loop shows up in a variable meant for something else. While
   such quirks can be taken advantage of, one is better off getting the value as
   intended via the comment ID 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Return multiple comment_meta keys’ is closed to new replies.

## Tags

 * [comment-meta](https://wordpress.org/support/topic-tag/comment-meta/)
 * [Comments](https://wordpress.org/support/topic-tag/comments/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/return-multiple-comment_meta-keys/#post-5860783)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
