Pulling reviews using WP_Query | WordPress.org

[ad_1]

You can either use the [site_reviews_summary] shortcode or the glsr_star_rating function.

For example:

echo do_shortcode('[site_reviews_summary assigned_posts="post_id" hide="rating,summary,bars"]');

Or:

$postId = get_the_ID();
$rating = get_post_meta($postId, '_glsr_average', true);
$reviewCount = get_post_meta($postId, '_glsr_reviews', true);

echo apply_filters('glsr_star_rating', null, $rating, $reviewCount);

You don’t need to cast the meta values to an integer/float as the helper function will sanitize the values for you.

And, if you want to sort your WP_Query by the average rating or the bayesian ranking, please see the examples on the Site Reviews > Help & Support > FAQ page.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer