admin管理员组文章数量:1277303
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/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' );
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/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' );
Share
Improve this question
asked Oct 1, 2021 at 21:06
irishrunner16irishrunner16
1071 gold badge1 silver badge8 bronze badges
2
|
1 Answer
Reset to default 0I 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.
本文标签: phpTag title not being returned in page title of tag archives
版权声明:本文标题:php - Tag title not being returned in page title of tag archives 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741290566a2370524.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
);
in the first clause, and iftribe_events_cat
etc are meant to be strings, they should be quoted. – vancoder Commented Oct 1, 2021 at 21:34is_tag()
conditions? Or does one of your otherif
clauses return true before it gets there? – vancoder Commented Oct 1, 2021 at 21:38