最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Insert text BEFORE the "tag" title

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

I 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

发布评论

评论列表(0)

  1. 暂无评论