• Resolved benbattaglia

    (@benbattaglia)


    How do I enable star ratings. I thought it was an add-on plugin but can’t find it anywhere?

    I want to enable them, and when enabled want to be able to sort my reviews by rating, is this possible?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Chris Dillon

    (@cdillon27)

    Here’s a quick tutorial on star ratings:
    https://strongplugins.com/document/strong-testimonials/star-ratings/

    To sort, we must alter the query with code. Add this to your theme’s functions.php or create an mu-plugin.

    /**
     * Sort by custom field: rating
     * This will exclude ratings of zero stars.
     * For Strong Testimonials.
     */
    function my_testimonial_query_filter( $args, $atts ) {
    	// Replace rating with the name of your custom field.
    	$args['meta_key'] = 'rating';
    	$args['orderby'] = 'meta_value_num ' . $args['orderby'];
    	// Use 'DESC' for descending from 5 to 1, or 'ASC' for ascending from 1 to 5.
    	$args['order'] = 'DESC';
    	return $args;
    }
    add_filter( 'wpmtst_query_args', 'my_testimonial_query_filter', 10, 2 );
    Thread Starter benbattaglia

    (@benbattaglia)

    Would this work to sort the ratings using a dropdown?

    I.e. Sort by: Rating 5* (To show all 5* ratings)?

    Plugin Contributor Chris Dillon

    (@cdillon27)

    That code alters every testimonial query.

    There is no front-end UI (dropdowns, etc.) for sorting or filtering.

    There are no hidden features. What you see is what you get. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Star Ratings / sort by rating’ is closed to new replies.