0

I am using this code to add the category title to the category archive titles:

function filter_events_title( $title ) {
  // Single venues
  if ( tribe_is_venue() ) {
    $title = sprintf('%1$s Running Race Calendar', get_the_title() );
  }
  // Category pages
  elseif ( tribe_is_upcoming() && is_tax() ) {
    $title = sprintf('%1$s Race Calendar', single_cat_title() );
  }
   
  return $title;
}
add_filter( 'tribe_events_title_tag', 'filter_events_title' );

While the category title is being output, it is BEFORE the opening tag. How can this be fixed so it is within the tags? Here's the source code:

5K  <title> Race Calendar &#8211; Running World</title>

1 Answer 1

2

You can fix that by setting the second parameter for single_cat_title() to false, which then returns the title instead of echoing it (before the <title> tag), like so:

$title = sprintf('%1$s Race Calendar', single_cat_title( '', false ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.