首页 文章

更改Wordpress标签页的 Headers

提问于
浏览
1

我希望更改我的wordpress博客的标签页面的 Headers . 我想要做的是将标记名称仅保留为 Headers .

例如:如果标签名称为“Wordpress标签页面教程" then that tag should have the same title " Wordpress标签页面教程" instead of "博客名称 - Wordpress标签页面教程”那么在此代码中要更改什么?我试过但在wordpress Headers 中只显示变量名称等错误 .

<title>
<?php if (is_home () ) { bloginfo('name'); }elseif ( is_category() ) {
single_cat_title(); echo ' - ' ; bloginfo('name'); }
elseif (is_single() ) { single_post_title();}
elseif (is_page() ) { bloginfo('name'); echo ': '; single_post_title();}
else { wp_title('',true); } ?>

2 回答

  • 2

    你错过了 is_tag() .

    例:

    if ( is_tag() ) {
        $tag = single_tag_title("", false);
        echo $tag;
    }
    
  • 0

    如果站点中安装了任何SEO插件,它将覆盖'wp_title'功能 . 因此,您可以在该插件设置中管理 Headers 字符串 .

    如果没有这样的插件,您可以使用以下代码:

    add_filter('wp_title', 'hs_tag_titles',10);
    
    function hs_tag_titles($orig_title) {
    
        global $post;
        $tag_title = 'Test Title';
        if ( is_tag() ) {
            return $tag_title;
        } else {
            return $orig_title;
        }
    }
    

相关问题