I’ve done exactly something similar. First, use get_comment_meta
for getting the per comment rating, you don’t need the SQL for it. Then get the average rating (addition of individual comment ratings on a single post / number of comments on this post). Then store this average value as post meta for this post. Use WP_Query
custom fields parameters for ordering these posts.
Related Posts:
- How to get a value from comment meta
- What for is the table “wp_commentmeta” exactly?
- Getting Post Comments for post ID using WP_Query() and a Custom Loop?
- Running a function on comment status change
- Is it possible to show custom comment metadata in the admin panel?
- Add Comment Custom Field
- Upload images with comment
- Add a drop down list to comment form?
- An action hook where a comment meta is updated
- What are the additional fields in wp_comments used for?
- Display comment meta data after quick update
- WordPress Comment. Need some details of wp_comments DB table
- How would I count the number of times a comment meta field’s value is in a post’s entire comments?
- Get comments from post and sort by commentmeta value
- How to get comment images stored as serialized comment meta
- Name of comment field differs on different sites
- Make every comment go to the spam folder
- How to display comment meta under each comment content
- Update comment meta for all comments of specific post
- How to get Post title by locale with Qtranslate-X
- get_comment_meta not behaving as expected
- How / where is the wp_query object created for RSS feeds?
- How to filter comments by comment_meta
- Top rated posts Average rating issue
- WordPress Commenting System User access and Security
- Add comment meta
- Comment-Meta doesn’t work with latest wordpress update
- add field comment [duplicate]
- Loop not displaying comments_popup_link
- Use country flag as user avatar based on comments IP address?
- Nofollow the date/time hyperlink in comment
- How do I comment out a block of tags in XML?
- R: Comment out block of code
- Why do I get comment spam even with Akismet and Captcha?
- What tools are available for managing/writing to WordPress? [closed]
- How to rearrange fields in comment_form()
- setting comments off as default for pages and custom post types?
- Is it possible to pull comments from facebook into your blog?
- Find out which moderator approved comment?
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- Non-threaded comment replies with link to original comment
- Approve comment hook?
- Commenting in user profile page?
- How to change “You must be logged in to post a comment.”
- comment_post_ID 0 (cannot remove from dashboard)
- Disable comments on all posts/pages
- How do I delete all comments from a specific old blog post?
- Removing the “Website” Field from Comments and Replies?
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- How to wrap submit button of comment form with div
- How to enable comments for pending and draft posts?
- Using WordPress’ WYSIWYG for comments
- Enable Submit Comment Without Page Reload (Using Ajax)?
- Add option to disable comments on a per posts basis?
- Resetting comment count
- When importing – failed to import: Invalid post type feedback
- How to change the email notification recipient (user) for new comments?
- Redirect user to a custom url after submitting the comment
- Paginate result set from $wpdb->get_results()
- Change Comment Author Display Name
- Would switching to InnoDB from MyISAM improve performance of comments table?
- Custom comment type based on thread level
- How to add internal, revision comments to page updates
- How to load and show comments with AJAX instead of pagination?
- Linking to Page Showing Only Comments Without Parent Post
- Comment Reply javascript
- How do we remove the H3 tag for the reply-title I.D
- Comments not appearing at all
- comments reply script not working
- How to display comment form error messages in the same page
- Easily invalidate form in comment_post hook
- The last comments of a post for the author of that post
- Page to view single comment and all replies
- Add ACF Quick Edit Columns on Comments
- How can I filter the user avatar displayed in comments? – get_avatar_url filter works everywhere but not in comments
- Best method for comment section associated with different images?
- Add functionality to block comment authors in the Comment edit pag
- Restrict users to see only own comments and the post author’s replies
- 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
- How can I add a check and not send an auto-reply to certain comments if the user fills in a custom field?
- Show success message on comment submit when email and name is not required field
- WordPress Editor widgets “comments” and “post comments form” getting disappeared with elementor [closed]
- Add pending for reply comment in console WordPress
- Show/Hide comments
- How to remove website url field from comment form completely?
- Remove rel=”nofollow ugc” from links in comments
- Why does the reply link in comments template scroll to comment position?
- My comments are blank in the backend
- Hide comments from admin comments.php that user can’t edit or manage
- Paste URL In comment It auto turn to default title of page with link
- How to hide newly added comments after 24h?
- Posting a comment on a blog post loads another blog post and comment is linked to the new blog post
- Fake email address with comment
- Show/hide comment status in front-end
- wp_verify_nonce for comment form is not returning false
- How can I not redirect users to the single post when they add a threaded comment?
- Make comment textarea input un-required