Skip to content

Instantly share code, notes, and snippets.

@lelandf
Created September 21, 2021 16:09
Show Gist options
  • Save lelandf/cc7d843cf55cb922d691649a6c148937 to your computer and use it in GitHub Desktop.
Save lelandf/cc7d843cf55cb922d691649a6c148937 to your computer and use it in GitHub Desktop.
[TEC] Set doctitle to include event category name.
<?php
add_filter( 'pre_get_document_title', function( $title ){
if ( is_tax( 'tribe_events_cat' ) ) {
$queried_object = get_queried_object();
// Set title to: [Tribe Events Category Name] - [WordPress Site Title]
$title = $queried_object->name . ' - ' . get_bloginfo( 'name' );
}
return $title;
}, 21, 1 );
@welbinator
Copy link

This works quite well with one exception: switching to Month view doesn't update the title correctly unless you refresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment