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
- Resetting comment count
- Redirect user to a custom url after submitting the comment
- Add comments from the admin panel?
- One comment per user per post but be able to reply to existing comments
- What’s the easiest way to close comments on media/attachments?
- Using Disqus, how to stop storing comments in wp database?
- Multiple Comment Moderators and Notifications
- function to remove ‘comments and trackbacks are closed’
- Get threaded comments number
- SQL query to delete comments older than 90 days?
- Let user edit his own comment
- Get the number of comments awaiting moderation
- Changing position of cancel_comment_reply_link and other elements of comment form
- What does the “$depth” parameter in the Walker_Comment stand for?
- Why do comment moderators need to have all create/edit/delete toboth posts and pages?
- Comment pagination – How to show determined number of comments on the first page?
- How to allow a particular role like Contributor be able to only view pending comments and approve them?
- How do I really disable comments?
- Sort comments by karma
- Bots posting comments on pages
- Comment form connection to Gravity Forms
- Add classname comment template from functions.php
- Comments deactivated
- List user comments in author page
- Filter custom posts with / without comments
- Create comments.php form of custom HTML code
- Display comments on homepage of twenty seventeen theme
- How to dynamic Heart Like in WordPress?
- Disqus comments and pingback script – how to change the order?
- To whom do emails get sent via the WordPress comments form?
- Is it possible to embed github gists in wordpress comments?
- Comments feed – Undefined named entity: ndash
- Error While Sending Comment
- How to convert WordPress comments to bbPress replies [closed]
- Get declared variable in single.php to work in comments.php without re-declaring it [closed]
- What is causing wp-comments-post.php to redirect to the browser’s IP address?
- Extra Title field for Comments
- Comments offset
- How to hide trackbacks on wp-admin/edit-comments.php
- comments_number not displaying
- Using a static callback on wp_insert_comment
- WordPress Recent Comments Widget exclude own comments
- How to prevent multiple comments
- Hide comments on specific pages, not just disable future comments
- Add comment_meta to wp_comment_reply
- How do comments work?
- Can’t reply to comments [closed]
- What’s the difference with trash_comment and wp_trash_comment?
- ask and edit an extra comment field
- Refresh individual comment text via API
- Prevent users to delete comments from trash
- How to display replies to his comments in user profile of current user
- How do I refresh “Post Last Modified Time”, as long as comment is updated to Approve status?
- stop url changing when user comments
- Badges for Guests based on their comment counts [closed]
- How to add a class to comment submit button?
- WordPress Comments – Only show part of user name
- Broken comments section – WordPress 2014 Theme
- Need an advice about comments
- How do I get the comments section to show up?
- By Default, Turn Comments Off for Pages & Leave Comments On for Posts
- same comment list for two posts
- Replace do_action() with a normal submit form in comments.php
- edit-comments.php in Admin – how to change ‘Comments’ title?
- Comments on pages not appearing, even though I enabled them
- Stop future commenting on specific post
- The last comments of a post for the author of that post
- Remove rel=”nofollow ugc” from links in comments
- How can I not redirect users to the single post when they add a threaded comment?