Product Reviews – how to get the overall rating

[ad_1]

Greetings Blocksy people!

I would like to display the average rating of my current product review in Elementor by using their Star Rating Widget with the Dynamic Tags functionality.

The problem is that, I can’t find any field that contains this data in a format like “4.6”.

As a workaround I ended up creating a shortcode that writes out the HTML of the rating with the “blocksy_get_product_review_overall_score” function like this:

add_shortcode('blocksy_overall_score', function () {
    $id = get_the_ID();
    $output="";

    if (function_exists('blocksy_get_product_review_overall_score') && $id) {
        $output = blocksy_get_product_review_overall_score($id);
    }
    echo $output;
});

In a similar way, I could also create a shortcode that returns the rating in number format.

Do you have a better idea? Perhaps could you introduce additional shortcodes to return the overall scores, as well?

 

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