Below, you’ll find a detailed guide on how to add the Widget Google Reviews Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the for Google Reviews Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Widget Google Reviews Plugin and the shortcodes it provides:
"Plugin for Google Reviews is a WordPress tool that enables you to effortlessly integrate and display Google Reviews on your website, enhancing your site's credibility and trust."
- [grw]
Widget Google Reviews [grw] Shortcode
The Widget-Google-Reviews plugin shortcode ‘grw’ initializes the display of Google reviews. It checks if the plugin is active, then retrieves and renders the reviews based on provided place_id or id.
Shortcode: [grw]
Parameters
Here is a list of all possible grw shortcode parameters and attributes:
place_id
– Identifier for a specific Google Place to get reviews from.id
– Identifier for a specific feed stored in the plugin.grw_active
– Controls if the plugin functionality is active or not.grw_demand_assets
– Decides whether to load the plugin’s public styles and scripts.
Examples and Usage
Basic example – A basic usage of the shortcode to initialize the Google Reviews Widget plugin. This shortcode does not require any additional parameters.
[grw /]
Advanced examples
Using the shortcode to display Google Reviews for a specific place by referencing the place_id. The widget will fetch and display reviews for the specified place.
[grw place_id="ChIJN1t_tDeuEmsRUsoyG83frY4" /]
Using the shortcode to display Google Reviews for a specific ID. If the ID does not exist, the widget will not display anything.
[grw id="12345" /]
Using the shortcode to display Google Reviews for a specific place and also enqueue public styles and scripts by setting grw_demand_assets to true. This will enhance the display of the reviews on the front-end.
[grw place_id="ChIJN1t_tDeuEmsRUsoyG83frY4" grw_demand_assets="true" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [grw]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('grw', array($this, 'init'));
Shortcode PHP function:
function init($atts) {
if (get_option('grw_active') === '0') {
return '';
}
if (isset($atts['place_id']) && strlen($atts['place_id']) > 0) {
$feed = $this->feed_old->get_feed($atts['place_id'], $atts);
} else {
$atts = shortcode_atts(array('id' => 0), $atts, 'grw');
$feed = $this->feed_deserializer->get_feed($atts['id']);
if (!$feed) {
return null;
}
}
$grw_demand_assets = get_option('grw_demand_assets');
if ($grw_demand_assets || $grw_demand_assets == 'true') {
$this->assets->enqueue_public_styles();
$this->assets->enqueue_public_scripts();
}
$data = $this->core->get_reviews($feed);
return $this->view->render($feed->ID, $data['businesses'], $data['reviews'], $data['options']);
}
Code file location:
widget-google-reviews/widget-google-reviews/includes/class-feed-shortcode.php
Conclusion
Now that you’ve learned how to embed the for Google Reviews Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply