• Resolved inscho

    (@inscho)


    Hi, I am using the review widget within my sidebar. Now I wanted to tag the site with Google Data Highlighter and ran into the issue that I could only tag the review-text and the review writer but not the given rate (points) because the Data Highlighter does not recognise the stars. It simply cannot evaluate them since they are graphics. Is there a way I could publish the rating with your standard widget or will I have to create a custom one?
    BR

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    You can add something like this to your active theme’s functions.php file:

    /**
     * Add the rating value to the review using a "data-rating" attribute 
     * @param string $renderedReview
     * @param array $rendered
     * @param object $review
     * @return string
     */
    add_filter( 'site-reviews/rendered/review', function( $renderedReview, $rendered, $review ) {
        $search = '<div class="glsr-review"';
        $replace = $search.' data-rating="'.$review->rating.'"';
        return str_replace( $search, $replace, $renderedReview );
    }, 10, 3 );
    

    Please also have a look at the shortcode documentation for a description of the schema attribute, and then read this to learn how you can customise the generated JSON-LD schema.

    • This reply was modified 8 years, 1 month ago by Gemini Labs.
    Plugin Author Gemini Labs

    (@geminilabs)

    I haven’t heard back from you in over a week so I will mark this as resolved.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Review Rating (value) missing within widget’ is closed to new replies.