Advertisement
geminilabs

[site-reviews] add rating Post Excerpt block

Aug 4th, 2023
1,756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /**
  2.  * Prepend the Post Excerpt block with the Site Reviews rating summary stars
  3.  * Paste this in your active theme's functions.php file.
  4.  * @param string $content
  5.  * @return string
  6.  */
  7. add_filter('render_block_core/post-excerpt', function ($content) {
  8.     $postTypes = ['page','post']; // Replace the values in this array with the desired post_types
  9.     if (in_array(get_post_type(), $postTypes)) {
  10.         $shortcode = '[site_reviews_summary assigned_posts="post_id" hide="bars,rating,summary"]';
  11.         $shortcode = do_shortcode($shortcode);
  12.         return $shortcode.$content;
  13.     }
  14.     return $content;
  15. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement