Review rating in filter form

how to add review filtering in filter form so user can filter as per raiting and view only listing that is needed and filtered they set filter listing as per this how to set this in filter form immediate if there any code snippet or anything which i can user to add like this option in filter form permanent like price is permanaen in filter form

Hi,

Thanks for the suggestion.

At the moment, there is a built-in option to sort listings by rating, but we plan to add rating filtering in one of the future updates.

In the meantime, you can try the following snippet:

// Add rating options to the listing filter form.
add_filter(
	'hivepress/v1/forms/listing_filter',
	function( $form ) {
		$form['fields']['_rating'] = [
			'label'   => esc_html__( 'Rating', 'hivepress-reviews' ),
			'type'    => 'radio',
			'options' => [
				''  => 'Any',
				'4' => '4 and above',
				'3' => '3 and above',
				'2' => '2 and above',
			],
			'_order'  => 100,
		];

		return $form;
	}
);

// Keep the selected rating when visitors change sorting.
add_filter(
	'hivepress/v1/forms/listing_sort',
	function( $form ) {
		$form['fields']['_rating'] = [ 'type' => 'hidden' ];

		return $form;
	}
);

// Show only listings rated at or above the selected value.
add_action(
	'pre_get_posts',
	function( $query ) {
		if ( is_admin() || ! $query->is_main_query() || 'hp_listing' !== $query->get( 'post_type' ) ) {
			return;
		}

		$rating = isset( $_GET['_rating'] ) ? absint( $_GET['_rating'] ) : 0;

		if ( $rating < 1 || $rating > 5 ) {
			return;
		}

		$meta_query   = array_filter( (array) $query->get( 'meta_query' ) );
		$meta_query[] = [
			'key'     => 'hp_rating',
			'value'   => $rating,
			'compare' => '>=',
			'type'    => 'DECIMAL(3,2)',
		];

		$query->set( 'meta_query', $meta_query );
	},
	20
);

Please note that it’s just a starting point, so it may require further customization to fit your needs.

Hope I helped with your request