2017-11-13

jQuery Plugin for showing google places reviews

Inspired by Steven Monson's magnificent article here: https://www.launch2success.com/guide/display-google-reviews-website-2017/ or check out Steven's github. Steven's code is based on peledies jquery plugin repo. So, I simply remixed their work into this little gem of code poetry. Thank you guys!

Source Code on GitHub

https://github.com/simonneutert/jquery-google-reviews

Prerequisites

Call the Plugin

Grab your place's ID (https://developers.google.com/places/place-id) and call it as placeId parameter, when calling the plugin.

<script>
  jQuery(document).ready(function ($) {
    if ($("#google-reviews").length == 0) {
      return;
    }
    // Find a placeID via https://developers.google.com/places/place-id
    $("#google-reviews").googlePlaces({
      placeId: "ChIJZa6ezJa8j4AR1p1nTSaRtuQ",
      // the following params are optional (default values)
      header: "<h3>Google Reviews</h3>", // html/text over Reviews
      footer: "", // html/text under Reviews block
      max_rows: 6, // max rows of reviews to be displayed
      min_rating: 4, // minimum rating of reviews to be displayed
      months: [
        "Jan",
        "Feb",
        "Mär",
        "Apr",
        "Mai",
        "Jun",
        "Jul",
        "Aug",
        "Sep",
        "Okt",
        "Nov",
        "Dez",
      ],
      text_break_length: "90", // length before a review box is set to max width
      shorten_names: true, // example: "Max Mustermann" -> "Max M.""
    });
  });
</script>

← Previous Post | Next Post →