Created
October 5, 2017 13:33
-
-
Save vicskf/983ac86e8b5b4eb535c79e22d53b8da1 to your computer and use it in GitHub Desktop.
The Events Calendar > Defines alternative title for recurring event views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Defines alternative title for recurring event views. | |
* Based on: https://theeventscalendar.com/knowledgebase/changing-the-browser-title-for-calendar-views/ | |
* | |
* @param string $title | |
* @return string | |
*/ | |
function filter_events_title( $title ) { | |
// Single Recurring events | |
if ( tribe_is_event() && is_single() && tribe_is_recurring_event() ) { | |
$event_title = get_the_title(); | |
$event_start_date = tribe_get_start_date( get_the_ID() , false, 'm/d/y' ); | |
$title = $event_title . ' [' . $event_start_date . ']'; | |
} | |
return $title; | |
} | |
/** | |
* Modifes the event <title> element. | |
* | |
* Users of Yoast's SEO plugin may wish to try replacing the below line with: | |
* | |
* add_filter('wpseo_title', 'filter_events_title' ); | |
*/ | |
add_filter( 'tribe_events_title_tag', 'filter_events_title' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment