I would try something like this:
$comments = get_comments();
$yes = 0;
$no = 0;
foreach ($comments as $comment) {
$vote = get_comment_meta ( $comment->comment_ID, 'vote', true );
if ($vote == 'yes') {
$yes++;
} else if ($vote == 'no') {
$no++;
}
}
echo 'Yes:'.$yes.' No:'.$no;
Problem is the numbers can easily be manipulated so it might be better to count only one vote per user_id, comment_author or comment_author_IP depending on your usage.
Codex: get_comments – get_comment_meta
Related Posts:
- Getting Post Comments for post ID using WP_Query() and a Custom Loop?
- What are the current recommended best-practices for comments.php?
- Threaded comments – deleting parent comment leads to orphan comments
- Does WordPress Allow Blank/Empty Comment Submissions In WordPress?
- Can I change what fields are displayed in the Comments form?
- Is it possible to move a comment that should be a reply to another comment?
- I have tried using Plugins to remove 72K comments with no success
- Change order of comment fields
- How to auto empty comment trash after X days
- Allow the comment author to delete their own comments
- Remove the deleted user comment
- Adding comments section to website integrated WordPress instance
- My posts show 2 comment forms
- Disallowed Tag Present in AMP WordPress ()
- Delete comments function
- I have tried using Plugins to remove 72K comments with no success
- Let user delete comment on front end only
- Deleting users do not deletes coments
- delete user not working
- Passing user meta through comment form
- Add option to disable comments on a per posts basis?
- What should I do to make generated avatars different for anonymous comments?
- Check If comment author is registered
- How do I set up real anonymous posting in bbpress forums? [closed]
- Adding another state (spam, reject, approve) to wordpress comments?
- How do I turn off wordpress comments ability to capture a users ip address?
- Success message in comment form
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Is there a hook for comment author link?
- Change the HTML output of comments
- How to Block Access to Standard Login Flow and Comment Flow
- Upload images with comment
- Prevent Contributor to show comment list
- where to modify get_comment_author_link()?
- Change language of comments template
- How to enable comments options?
- WordPress comment count to include attachment comments
- Remove “Comments are closed” Notice from Custom Post Type template
- Displaying comments with a walker: how to distinguish between parent and child comments
- Comment form problem with comment_author_url and HTML5 input placeholders
- How would I count the number of times a comment meta field’s value is in a post’s entire comments?
- Pings and replies
- Cannot get local avatars to show [closed]
- Posts vs. Pages
- WordPress comments on users profile
- wordpress threaded comments – customize nested ul / how child ul is displayd
- How to make a secure blog that is completely private?
- identify and delete spam comments from 3000 pending comments
- Hide comments column in WordPress backend
- How unrequire comment text in wordpress post
- Auto delete comment if Contains
- API Hook for After Commenting (for sharing on Facebook)
- Make WordPress process admin group comments using $allowedtags
- Can comments by a logged-in user be displayed at the top?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- Placed on + only date (not time)
- Loading Comments From a Class?
- How to get and use the the number of days since the last comment?
- Trying to post a wordpress comment on my site redirects to 127.0.0.1
- How do I add class to an admin comment?
- Best way to tell if a comment is from a user?
- Adding SQL source code to comments
- How to control size of comments popup window?
- How to make comments private for commentor and post author
- Name of comment field differs on different sites
- WordPress Spam Comment Filter
- Which hook do I use to edit pending comment count on wordpress dashboard?
- comment button shows only logged in users wordpress
- Applying same style to all the comments on the page
- Customise Comment form
- custom comment fields on CPT
- assumed as comment line
- stumped on add_action hook to delete_comment – any ideas?
- Avoiding calls to theme-compat
- Allow tags between shortcode in comments
- How to load new posts from wordpress db into wordpress homepage without refreshing the site?
- Delete/Spam Comment Button
- Who approved a comment, to show up in dashboard
- comments.php remove date/time’s #hyperlink
- comment just attachment .. reply just text … can I do that?
- I have an odd field with a purple background, mentioning HTML-codes to use while leaving comments
- No comment Section but still got a Comment
- How to prevent users/authors from seing IP/email of new commentators?
- Why are my threaded comments not quite working? [closed]
- $post->comment_status always returns ‘closed’
- Order comments in admin by custom date
- edit comments in front end
- How to replace anonymous comment form with a registration form on wordpress?
- How to get the 5 most recent comments and each comment 5 most recent replies (children)
- Redirect first time comments
- Posting XML in comment section
- comment files and s
- How to hold all comments for moderation, including author’s comments on own post
- Recent comments per tagged post?
- Subscribe to a post’s comments without posting a comment yourself
- WordPress error when sending comment
- Why default comment fields don’t show up?
- Query comments with non-empty ‘author_url’ value on Admin Comments Screen
- Customize the new comment notifications sent to the post author after the comment is approved
- Get approved comments or comments that the author is me