cliffordp
4/24/2017 - 3:22 PM

MT - TEC - Custom Events Archive <title> (browser tab text)

MT - TEC - Custom Events Archive (browser tab text)

<?php
/**
 * MT - TEC - Custom Events Archive <title> (browser tab text)
 *
 * from https://gist.github.com/cliffordp/9109ea4f072be52c3b923c224ab7eb2f
 * for https://theeventscalendar.com/support/forums/topic/how-to-rename-the-of-the-events-list/#post-1273004
 *
 * @return string
 */
function tribe_events_archive_custom_title( $title ) {
    $my_custom_title = 'My Custom Events Archive Title'; // change this!!!

    if ( ! class_exists( 'Tribe__Events__Main' ) ) {
        return $title;
    }

	$is_ajax        = defined( 'DOING_AJAX' ) && DOING_AJAX;
	$is_truly_admin = is_admin() && ! $is_ajax;

	if ( is_post_type_archive( Tribe__Events__Main::POSTTYPE ) && ! is_single() && ! $is_truly_admin && is_main_query() ) {
	    $title = esc_html( $my_custom_title );
	}

	return $title;
}

add_filter( 'tribe_events_title_tag', 'tribe_events_archive_custom_title' );