Add commentmeta custom field to every published comment with SQL

I assume you’re already properly using the WP Metadata API https://codex.wordpress.org/Metadata_API to attach the field to new comments and you just want to backfill for existing comments by stuffing the database? If it was my problem, I wouldn’t bother and would assume in my code that absence of meta implied no likes. If you use … Read more

Adding Comment Meta to a new comment notification email

The solution was to add a priority number to the comment_post action that was saving my rating value, as shown below: function save_comment_meta_data( $comment_id ) { if ( ( isset( $_POST[‘rating’] ) ) && ( $_POST[‘rating’] != ”) ) { $rating = wp_filter_nohtml_kses($_POST[‘rating’]); add_comment_meta( $comment_id, ‘rating’, $rating ); } } add_action( ‘comment_post’, ‘save_comment_meta_data’, 5 ); … Read more

How to get top rated posts using wp query?

Don’t worry. I have found solution for your issue. you can use below code to display 5 top rated posts based on average rating. i have created below function to get top average rated post using sql queries and wp_query functions. here is updated function for all custom post type. function top_rated_post_via_comment_of_CPT($post_per_page = 5){ global … Read more