X Features Cars Demo Power Plants Demo State Parks Demo Site Showcase Docs Tutorials Add-ons Buy

Using FacetWP with EDD Reviews

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.

Add the integration code

The following code goes into your (child) theme’s functions.php or into a custom plugin.

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!