Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Change the meta title for events.
- */
- function wi_override_events_page_title( $title, $sep ) {
- if ( ! tribe_is_event_query() || is_singular() ) return $title; // None of our business
- $sep = '|'; //So we're not using the default sep
- $query = $GLOBALS['wp_query']->query;
- $site_name = get_bloginfo( 'name' ); //To use the name at the end of our title meta tag
- //If on the main page then show Get Involved, otherwise tack on "| St. Louis Regional Health Commission"
- if ( ( 2 === count( $query ) || 3 === count( $query ) ) && ( $query['eventDisplay'] === tribe_get_option( 'viewOption' ) ) ){
- $title = 'Get Involved ' . $sep . ' ' . $site_name; //"Get Involved" is the name of the page where we display the calendar
- }
- else {
- //On all other event pages we want to replace the default $sep and add the site name if it's not already included
- $title = str_replace( '»', $sep, $title );
- if( strpos( $title, $site_name ) === false ) {
- $title = $title . ' ' . $site_name;
- }
- }
- return $title;
- }
- add_filter( 'wp_title', 'wi_override_events_page_title', 100, 2 );
Advertisement
Add Comment
Please, Sign In to add comment