Support » Plugin: Site Reviews » How to display list of reviews

  • Resolved redactuk

    (@redactuk)


    Hi

    Documentation says:

    $reviews = glsr_get_reviews([
    	'rating' => 3,
    ]);
    foreach( $reviews as $review ) {
    	glsr_debug( $review );
    }

    How do I actually output review content in that foreach loop?

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

    (@geminilabs)

    Simply generate your own HTML using using the $review object for values. Please also read the documentation for the glsr_debug helper function.

    If that is too advanced for you, I suggest you instead use:

    do_shortcode( '[site_reviews]' );

    Ok. Example kinda implies reviews is simply array you can loop through, which it’s not. Shortcode won’t do for me as I’ building slider of reviews.

    Anyway, what I needed was:

    $reviews = glsr_get_reviews([
    	'rating' => 3,
    ]);
    foreach( $reviews->results as $review ) {
    	echo $review->content;
    }
    • This reply was modified 1 year, 6 months ago by redactuk.
    Plugin Author Gemini Labs

    (@geminilabs)

    @redactuk Please wait for v3.2.0 to be released which will include updated documentation on how to render the reviews that have been fetched through the helper tools.

    Plugin Author Gemini Labs

    (@geminilabs)

    @redactuk please update to v3.2.0 and read the updated documentation.

    Excellent. Some nice changes there. Much appreciated.

    I may be able to get around this for now, but is there / or are you able to add helper function to render $review->rating into stars from a basic loop?

    Actually, never mind. I’ll use your markup for an individual review.

    • This reply was modified 1 year, 6 months ago by redactuk.
    Plugin Author Gemini Labs

    (@geminilabs)

    @redactuk you can do this:

    $reviews = apply_filters( 'glsr_get_reviews', [], [
        // options here
    ]);
    foreach( $reviews as $review ) {
        $reviewHtml = $review->build();
        echo $reviewHtml->rating;
        glsr_debug( $reviewHtml->rating ); // print the raw HTML to the page
    }

    The only thing is that if you do this, you may have to add your own CSS to display the rating as the existing CSS rules depend on the parent CSS classes.

    • This reply was modified 1 year, 6 months ago by Gemini Labs.
    • This reply was modified 1 year, 6 months ago by Gemini Labs.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display list of reviews’ is closed to new replies.