First user fill this custom comment form.
This is my meta_key i want that i want to fetch.
for every comment there are 10 rating.
I want to make below rating filter.But don’t know how to start.
This is what i tried yet.
add_action( 'comment_post', 'show_message_function', 10, 2 );
function show_message_function( $comment_ID, $comment_approved ) {
$comment = get_comment( $comment_ID );
if( empty($comment) ) {
return;
}
$post = get_post( $comment->comment_post_ID );
$post_comments = get_comments( ['post_ID' => $post->ID ] );
$meta_value = get_comment_meta($comment->comment_ID);
d($post);
// d($post_comments);
d($meta_value);
die;
}
function d($data) {
echo '<pre>', print_r($data), '</pre>';
}
UPDATE:
I created a post meta and save it in updated rating average every time a comment is posted.
Now want to make a filter as shown in above image, when any user click on checkbox against number of stars data must be filtered , and show those custom posts have average = chosen number of stars.