Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Facet Label = "Rating"
- // Facet Name = "rating"
- // Facet Data Source = "Post Type"
- 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 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement