PHP Snippet: Woocommerce Reviews as Shortcode
Are you using the Flatsome theme for your WooCommerce website and want to display product reviews in a shortcode?
With this tutorial, youāll learn how to easily add a custom PHP snippet to your Flatsome theme and create a shortcode to showcase the reviews of the current product. By following these step-by-step instructions, youāll be able to enhance your product pages and provide valuable social proof to your customers. Letās get started!

Access your WordPress admin dashboard.
Then, Go to āAppearanceā -> āEditorā.
In the right-hand sidebar, locate and click on āTheme Functions (functions.php)ā.
Scroll down to the bottom of the āTheme Functionsā file.
Add the following PHP snippet at the end of the file:
Click the āUpdate Fileā button to save the changes.
Now, you can add the
[product_reviews id=""]shortcode to any page or post where you want to display the product reviews. Edit the page or post where you want to add the shortcode.In the editor, place your cursor at the desired location to insert the shortcode.
Enter
[product_reviews id=""]at that location.Update or publish the page or post.
The provided PHP snippet adds a shortcode that will display the product reviews specific to the current product being viewed. The shortcode can be added to any page or post content using the [product_reviews id=""] shortcode.
Please note that itās important to always make a backup of your theme files before making any changes.
Last updated