Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // show approved reviews for product shortcode
- // usage: [show_reviews product_id="1234"]
- // code goes in functions.php for your child theme
- add_shortcode('show_reviews', 'show_reviews');
- function show_reviews($attributes) {
- $a = shortcode_atts( array('product_id' => 'product_id'), $attributes );
- $product_id = absint($a['product_id']);
- if (!$product_id) return;
- $args = array ('post_id' => $product_id, 'status' => 'approve');
- $comments = get_comments( $args );
- return wp_list_comments( array( 'callback' => 'woocommerce_comments', 'echo' => false ), $comments);
- } // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement