php – Tag title not being returned in page title of tag archives

Question

I am using the snippet below to add the category or tag title to their respective archive page title. While the category title is working as expected, the portion that is supposed to target the tag archive pages (e.g. example.com/events/tag/road-race/) is not having any effect on those page titles.

I tried removing tribe_is_upcoming() && so that it would only require that the query is for the post_tag taxonomy, but that isn’t working either. I also tried specifying the post_tag conditional as is_tag(post_tag) and that doesn’t have any effect.

I inspected the tag pages with the Query Monitor plugin and the following conditionals are true:
is_archive()
is_post_type_archive()
is_ssl()
is_tag()

The only difference in the tag conditionals vs category conditionals is that the category pages have is_tax() as being true, while the tag pages have is_tag() as true.

Am I using the wrong function (single_tag_title) or missing something else with the conditionals?

function filter_events_title( $title ) {
  // Single venues
  if ( tribe_is_venue() ) {
    //$title="Single venue page";
    $title = sprintf('%1$s Running Race Calendar', get_the_title() );
 );
  }
  // List view category page: upcoming events
  elseif ( tribe_is_upcoming() && is_tax(tribe_events_cat) ) {
    //$title="Category Running Race Calendar";
    $title = sprintf('%1$s Race Calendar', single_cat_title( '', false ) );
  }
  // List view category page: past events
  elseif ( tribe_is_past() && is_tax(tribe_events_cat) ) {
    $title = sprintf('%1$s Race Calendar', single_cat_title( '', false ) );
  }
  // List view tag page: upcoming events
  elseif ( tribe_is_upcoming() && is_tag() ) {
     $title = sprintf('%1$s Race Calendar', single_tag_title( '', false ) );
  }
  // List view tag page: past events
  elseif ( tribe_is_past() && is_tag() ) {
    $title = sprintf('%1$s Race Calendar', single_tag_title( '', false ) );
  }
   
  return $title;
}
add_filter( 'tribe_events_title_tag', 'filter_events_title' );

0
irishrunner16 3 weeks 2021-10-01T16:06:14-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse