How to filter custom post by rating star


First user fill this custom comment form.

first step

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.

final output

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) ) {

    $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_comments);


function d($data) {
  echo '<pre>', print_r($data), '</pre>';

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.


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="">

How to filter custom post by rating star</a>
inrsaurabh 2 years 0 Answers 38 views 0

Leave an answer