Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Displays the star rating above the excerpt when using the Posts in Sidebar plugin
- * This will only work if your pages or posts have reviews that have been assigned to them
- * Since the Posts in Sidebar plugin hardcodes the text in <p> tags, we have to use
- * the glsr_star_rating() function instead of the [site_reviews_summary] shortcode.
- *
- * Make sure to set the following widget options:
- * 1. Get posts with this meta key: _glsr_ranking
- * 2. Order posts by: Meta value number
- * 3. The order will be: Descending
- *
- * Paste this code in your theme's functions.php file.
- */
- function glsr_display_rating_in_pis_excerpt($content) {
- $rating = get_post_meta(get_the_ID(), '_glsr_average', true);
- $starsHtml = apply_filters('glsr_star_rating', null, $rating);
- $starsHtml = str_replace(['<div', '/div>'], ['<span', '/span>'], $starsHtml);
- $starsHtml = '<span class="glsr glsr-default">'.$starsHtml.'</span><br>';
- return $starsHtml.$content;
- }
- add_filter('pis_content', 'glsr_display_rating_in_pis_excerpt');
- add_filter('pis_excerpt_text', 'glsr_display_rating_in_pis_excerpt');
- add_filter('pis_more_excerpt_text', 'glsr_display_rating_in_pis_excerpt');
- add_filter('pis_only_read_more', 'glsr_display_rating_in_pis_excerpt');
- add_filter('pis_rich_content', 'glsr_display_rating_in_pis_excerpt');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement