I'd like to insert text BEFORE the "tag" title.
So, I am using Categories and Tags and I when I click into one of my "tag" archives the title of the page is simply the word of the "tag" so in my example it is "New York"
What I would like to do is insert text BEFORE "New York"
I thought this would work but it doesn't:
add_filter( 'get_the_archive_title', 'custom_tag_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function custom_tag_archive_title( $title ) {
if ( is_tag() ) {
$title = single_tag_title( 'Conferences In ', false );
}
return $title;
}
Now, the interesting thing is that I did the same for my categories and it works great. The function I am using is this:
add_filter( 'get_the_archive_title', 'custom_taxonomy_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function custom_taxonomy_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
elseif ( is_tax('country') ) {
$title = single_term_title( 'Conferences In ', false );
}
return $title;
}
Any ideas why the "tag" (which is a regular "tag") doesn't load the text before?
Thanks for all suggestions.
I'd like to insert text BEFORE the "tag" title.
So, I am using Categories and Tags and I when I click into one of my "tag" archives the title of the page is simply the word of the "tag" so in my example it is "New York"
What I would like to do is insert text BEFORE "New York"
I thought this would work but it doesn't:
add_filter( 'get_the_archive_title', 'custom_tag_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function custom_tag_archive_title( $title ) {
if ( is_tag() ) {
$title = single_tag_title( 'Conferences In ', false );
}
return $title;
}
Now, the interesting thing is that I did the same for my categories and it works great. The function I am using is this:
add_filter( 'get_the_archive_title', 'custom_taxonomy_archive_title' );
/**
* Remove archive labels.
*
* @param string $title Current archive title to be displayed.
* @return string Modified archive title to be displayed.
*/
function custom_taxonomy_archive_title( $title ) {
if ( is_tax('us_state') ) {
$title = single_term_title( 'Conferences In ', false );
}
elseif ( is_tax('country') ) {
$title = single_term_title( 'Conferences In ', false );
}
return $title;
}
Any ideas why the "tag" (which is a regular "tag") doesn't load the text before?
Thanks for all suggestions.
Share Improve this question asked May 9, 2019 at 11:51 HenryHenry 9831 gold badge8 silver badges31 bronze badges1 Answer
Reset to default 0I skipped this and figured out the best way as Pseudo CSS (I believe it is called)
body.tag .page-title:before {
content: 'Conferences In ';
}
^ this works well