Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Append the Site Reviews rating summary stars, if they exist, to the Page titles
- * Paste this in your active theme's functions.php file.
- * @param string $title
- * @param int $postId
- * @return string
- */
- add_filter('the_title', function ($title, $postId) {
- if (in_the_loop() && is_page()) { // only proceed for pages
- $shortcode = '[site_reviews_summary assigned_posts=post_id hide="if_empty,bars,rating,summary"]';
- $shortcode = do_shortcode($shortcode);
- $shortcode = str_replace(['<div', '/div>'], ['<span', '/span>'], $shortcode); // replace block-level elements
- return sprintf('<span>%s</span>%s', $title, $shortcode);
- }
- return $title;
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement