WP_Comment_Query
doesn’t pull comment meta. You can search by comment meta but the query doesn’t return that data. You could easily check this yourself by looking at the Codex.
You need to loop over the results and run get_comment_meta()
, or essentially do the same via a filter on the_comments
.
It is also possible to add to the data returned by filtering the “fields” clauses:
function add_cmeta_wpse_212423($clauses){
// var_dump($clauses);
global $wpdb;
$meta = "(SELECT meta_value
FROM {$wpdb->commentmeta}
WHERE (
comment_id = comment_ID
AND meta_key = 'test_comment_meta')
) as test_comment_meta";
$clauses['fields'] .= ', '.$meta;
return $clauses;
}
add_filter('comments_clauses','add_cmeta_wpse_212423');
I created a subquery. You could create a JOIN
as well.
Related Posts:
- Why does comment_reply_link launch the reply form at the wrong spot on the comment section?
- Threaded Comments Feature not working
- customizing TwentyEleven comments template
- Enable nested comments in Theme
- Remove the function which adds nofollow to links in comments
- Removing(replacing) avtar in comments.php with some other HTML arrangements
- Cannot display comment in page
- How to rearrange fields in comment_form()
- Removing the “Website” Field from Comments and Replies?
- How to add a class to the comment submit button?
- How to wrap submit button of comment form with div
- Comment Walker vs. Comment Callback
- comments reply script not working
- How to display comment form error messages in the same page
- Why does `add_theme_support( ‘html5’, array( ‘comment-form’ )` disable client side validation?
- Add class to Reply button in Comments area
- How do I set up real anonymous posting in bbpress forums? [closed]
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Deep customization of the comment form?
- Custom Comments – Parent / Nested Reply
- Using filter to add additional fields to comment_form()
- Why are default comments deprecated?
- Comments Reply Form
- Does WordPress Allow Blank/Empty Comment Submissions In WordPress?
- Comment form not display properly?
- Comment form not showing up without comments
- Programmatically block commenting by restricting view of comment form
- Hide comment form completely (preferably without using CSS)
- How can comments be submitted when I don’t have a comment box on a page?
- comment_form() generates the wrong action url
- Add comments meta fields to comments metabox on post edit screen
- Custom Field Added In Comment Form Not Showing In Edit
- Display comments on a comment page without form
- Add a drop down list to comment form?
- How To Remove The “Click here to cancel reply” Link From The WordPress Comment Form
- Change “logged in” link in (you must be logged in to post a comment)
- Change the tag of the comment submit button
- Comments form custom fields order
- changing default comment form arguments [duplicate]
- Making a Comment on a page without being on that page?
- customize comment form
- adding a text message beside the comment submit button
- How to save new comment as custom comment type?
- WP comments form (custom) is displaying an extra comment field
- How to modify comments form using comment_form()?
- How to add consent checkbox in comment section
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- How to add enctype to multipart/form-data to comment form?
- How to change the order of elements in comment_form()
- Changing position of cancel_comment_reply_link and other elements of comment form
- Publish a message on facebook after having posted a comment
- Including new Javascript only after a comment is made
- Show comments fields in two columns
- Edit Comment_Field while using T5 Comment Textarea On Top-Plugin
- How to add a title field in comments?
- Two steps comment form
- Share comment to twitter after publishing [closed]
- Customize the cancel_comment_reply_link
- Disable comments
- How to add attributes to the comment form tag?
- Comment form connection to Gravity Forms
- Auto-fill Custom comment fields
- The comment login form is visible to me but not to the user
- How to enable commenting system in WordPress
- Change order of comment fields
- How to call my custom WordPress Comment form without getting the comments?
- Create comments.php form of custom HTML code
- comment_form() Not changing the default class/id of elements
- How can I get values count from wp_commentmeta?
- How can I test why the comment hook is not working?
- How can I convert anonymous commenters into registered users?
- How to modify core when there is no hook?
- comment_post action hook running on page load instead of after a comment is posted
- “comments.php” not available after edit in WP administration
- Add class to comment form div when comment-reply button is clicked
- To whom do emails get sent via the WordPress comments form?
- Jetpack Comments with fall-back
- blank page after submitting a comment
- Display complete comment section via post ID
- Insert page comment form into a modal
- changing font size and font of a custom message added after comment
- Notification if Comment Author Field is left empty. E.g. change input border colour
- Is it possible to force login for comments only on custom-post-type or the custom comment template?
- Assign author to comment from post edit page
- How to retain comment text on comment form after login/registration?
- Highlight comments of all the site authors
- Check if comment was successfully submited
- Force logged in users to still fill out name/address for commenting?
- What functions does WordPress use for filtering / sanitizing comments?
- How to add a “policy text” just before the comments? [closed]
- Ajax submit comments
- Why could my comment_form variable not be working?
- WordPress comment submit button substitutes/options
- Wrapping the cancel_comment_reply_link()
- Does anyone know all parameters of get_comments()
- Display avatar with comment form?
- Commentform input area issue
- How to make comments private for commentor and post author
- Name of comment field differs on different sites
- Use of comment_reply_link_args filter