Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('the_title', 'tribe_restore_title');
- /**
- * Tries to detect if the content is The Events Calendar related and returns the expected title. Useful where a theme
- * displays the post/page title in a certain format before the event content is injected.
- *
- * Targets TEC 3.0.2. Notes: it looks on face value like better use could be made of tribe_is_event_query() and
- * tribe_is_event() here, but because we're early in the request and want to avoid notices we'll avoid those.
- *
- * @param $title
- * @return string
- */
- function tribe_restore_title($title) {
- global $wp_query;
- global $post;
- if (-9999 !== $post->ID) return $title;
- if ( ! isset($wp_query->tribe_is_event) || ! $wp_query->tribe_is_event) return $title;
- if ( ! is_a($wp_query->posts[0], 'WP_Post') || $wp_query->posts[0]->ID == $post->ID) return $title;
- if (is_singular()) return $wp_query->posts[0]->post_title;
- else return tribe_get_events_title();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement