The EDD Reviews plugin lets users attach ratings and reviews to Easy Digital Downloads (EDD) products. With the following steps, you can use FacetWP to filter by average rating.

Create the facet

The first step is to create a new facet.

  • Enter Rating as the Label (name = “rating”).
  • We recommend either Slider or Star Rating as the facet type.
  • Choose Post Type as the Data source.

Add the integration code

The following code goes into your (child) theme’s functions.php or into the Custom Hooks add-on.

How to use custom PHP code?

PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info

function fwp_edd_average_rating( $params, $class ) { if ( 'rating' == $params['facet_name'] ) { global $post; $post = is_object( $post ) ? $post : new stdClass(); $post->ID = $params['post_id']; // simulate the global post ID $rating = edd_reviews()->average_rating( false ); $params['facet_value'] = $rating; $params['facet_display_value'] = $rating; } return $params; } add_filter( 'facetwp_index_row', 'fwp_edd_average_rating', 10, 2 );

Finally, hit the re-index button. That’s it!

See also