0

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' );
2
  • 2
    Is this your actual code? because you have a rogue ); in the first clause, and if tribe_events_cat etc are meant to be strings, they should be quoted.
    – vancoder
    Oct 1 '21 at 21:34
  • 1
    Does the parsing even get as far as the is_tag() conditions? Or does one of your other if clauses return true before it gets there?
    – vancoder
    Oct 1 '21 at 21:38
0

I found my error. I had elseif ( tribe_is_upcoming() && ! is_tax() ) as a previous conditional, so that was getting applied to the tag pages before it got to the is_tag() conditions. Correcting this to elseif ( tribe_is_upcoming() && ! is_tax() && ! is_tag() ) allowed it to get to the is_tag() conditions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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