Guest User

The Events Calendar Pro Title Tag Override

a guest
Aug 17th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. /**
  2.  * Change the meta title for events.
  3.  */
  4. function wi_override_events_page_title( $title, $sep ) {
  5.   if ( ! tribe_is_event_query() || is_singular() ) return $title; // None of our business
  6.  
  7.   $sep = '|'; //So we're not using the default sep
  8.   $query = $GLOBALS['wp_query']->query;
  9.   $site_name = get_bloginfo( 'name' ); //To use the name at the end of our title meta tag
  10.  
  11.   //If on the main page then show Get Involved, otherwise tack on "| St. Louis Regional Health Commission"
  12.     if ( ( 2 === count( $query ) || 3 === count( $query ) ) && ( $query['eventDisplay'] === tribe_get_option( 'viewOption' ) ) ){
  13.     $title = 'Get Involved ' . $sep . ' ' . $site_name; //"Get Involved" is the name of the page where we display the calendar
  14.   }
  15.   else {
  16.     //On all other event pages we want to replace the default $sep and add the site name if it's not already included
  17.     $title = str_replace( '»', $sep, $title );
  18.     if( strpos( $title, $site_name ) === false ) {
  19.       $title = $title . ' ' . $site_name;
  20.     }
  21.   }
  22.  
  23.     return $title;
  24. }
  25. add_filter( 'wp_title', 'wi_override_events_page_title', 100, 2 );
Advertisement
Add Comment
Please, Sign In to add comment