Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Registers the [site_reviews_random] shortcode to display a random review
- *
- * Shortcode options can be any of the "glsr_get_reviews" function arguments
- * outlined in the documentation (except for "orderby" and "pagination").
- *
- * Note: this will obviously not work if you are caching your pages.
- *
- * @param array $atts
- * @return string
- */
- add_shortcode('site_reviews_random', function ($atts = []) {
- $atts = wp_parse_args(['orderby' => 'random', 'pagination' => false], $atts);
- if ($reviews = apply_filters('glsr_get_reviews', null, $atts)) {
- $html = $reviews->build();
- return sprintf('<div %s>%s</div>', $html->attributes, $html);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement