Recently a client asked me about “How to display WooCommerce reviews on the homepage. He wanted to get all the different product reviews out of the system and display the 6 reviews on the home page with the title and a link to the product that the review was for. In this post I will show you How to display WooCommerce reviews on any page of your choice. In fact I will also show you how to generate a shortcode for it because I have already done this work and I can post the code for the community and save someone else a bunch of time.
Personally, I think its a great idea to display product Reviews on landing pages for marketing purposes. Its easier to sell a product if it has already established the credentials in the eyes of a customer. Please keep in mind that you will need a “Child Theme” if you are working with a theme that you will want to update in the future. The reason is we want to preserve our code and keep the theme in use free of any customization work. I assume for the sake of this post that you are familiar with what a Child Theme Is.
How to display WooCommerce reviews
Woocommerce Product Reviews are basically stored with the comment system in the WordPress System. Internally they are stored as Post Comments. WooCommerce also creates a taxonomy for the post_type Product. In my example we will retrieve any product reviews. To do that I will use the WP_COMMENT_QUERY which was introduced and available in WordPress 3.6.X release (I believe, I might be wrong).
The First Step
The first step is to create a php function in functions.php. Again a friendly reminder that you should be using a Child Theme. Always back up before making modifications because syntax errors in functions.php are fatal. In the function you can use code similar to the one pasted below to retrieve comments from the system that apply to products