如何让logger中文版使用WordPress新的站点文章标题管理方式

导语:在老版的WordPress中,我们在header.php中使用wp_title()函数来管理标题,但在新版的WordPress中,已经开始放弃这种方式,开始启用全新的方式来管理站点文章标题。为了适应这种改变,我们可以将LOGGER主题的标题管理升级为新的方式。

删除logger中文版旧的文章标题管理方式

我们需要打开header.php文件,然后找到下面的代码:

<title><?php wp_title( '|', true, 'right' );?></title>

将此代码删除掉,因为我们会在functions.php文件中启用全新的方式,所以这行代码已经没有用了。

添加logger中文版新的文章标题管理方式

打开functions.php文件,找到函数vbegy_load_theme() ,在它里面添加以下代码:

add_theme_support( 'title-tag' );

然后再在functions.php文件的尾部,添加以下代码,请按实际需要添加:

//自定义标题分隔符
function Bing_title_separator_to_line(){
    return '-';
}
add_filter( 'document_title_separator', 'Bing_title_separator_to_line' );

//新的 WordPress 网页标题设置方法
if (!function_exists('leaf_pre_get_document_title')) :
function leaf_pre_get_document_title(){
   if( is_home()||is_front_page() ) {$title = '首页标题-WordPress Leaf';
   }elseif ( is_category(2) )  {$title = '分类二的标题-WordPress Leaf';
	 }elseif(is_page(12))  {$title = '页面十二的标题-WordPress Leaf';}
	 
   return $title;//自定义标题内容
}
endif;
add_filter( 'pre_get_document_title', 'leaf_pre_get_document_title');

关于分隔符

你可以自己定义标题的分隔符,一般来说,我们可以使用“-”、“_”、“|”这三种,可根据自己的喜好来,但是,叶子在这里要说的是,谷歌会把“_”视为空,所以一般来说,国外用“-”的网站居多。

把“_”视为空会出现什么情况,举例说明,比如“WordPress_leaf”,我们用“_”把它分隔为两个词,那么谷歌在采集的时候,会把把“_”清除掉,采集内容会变成“WordPressleaf”这一个词。而“-”,谷歌会将它视为空格,那么你的标题还是用空格间隔的两个词,“WordPress leaf”。

当然,对于国内,对于中文站来说,谷歌对网站的影响不大,一般是百度,百度对于这个分隔符,似乎没有明确的规定,如果注意观察,你会发现国内的各个大站,在使用各式各样的分隔符,这里就不一一举例的,请自行观察。

下载logger中文版

你可以前往自媒体个人WordPress主题 LOGGER汉化中文版 免费下载下载由叶子汉化的Logger中文版。

结束

好了,你学会了吗?如果你需要新的标题管理的更多文档,可以前往WordPress文档库。


Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/12.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

目前在“如何让logger中文版使用WordPress新的站点文章标题管理方式”上有4条评论


  1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

    Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

    Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/67.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
    智慧果说道:

    多谢大大帮我搞的网站啊。


    1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

      Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

      Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/31.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
      编辑 杨说道:

      好吧,你怎么可以评论,我这篇文章没有发布呀。


      1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

        Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

        Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/27.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
        智慧果说道:

        明明发布了好吧,不然我怎么看得到


        1. Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

          Warning: copy(): Failed to enable crypto in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546

          Warning: copy(https://www.wordpressleaf.com/wp-content/themes/summerleaf/images/tx/47.png): failed to open stream: operation failed in /opt/lampp/htdocs/wordpresssummer/wp-content/themes/summerleaf/inc/summer_setting.php on line 546
          编辑 杨说道:

          那是你,其他人看不到的。

发表评论

邮箱地址不会被公开。 必填项已用*标注