A-A+
给WordPress主题增加头条搜索的“时间因子提交”功能
时间因子提交是头条搜索为了解决:目前站外存在落地页页面时间标注不清、页面无时间等对用户浏览体验不友好情况。开放对落地页时间因子的提交规范,有助于帮助搜索用户获得更满意的搜索浏览体验,帮助优质站点获取更多展现机会。
时间因子的格式是什么?
- <meta property=”bytedance:published_time” content=”2022-12-11T12:28:44+01:00″ />
- <meta property=”bytedance:lrDate_time” content=”2022-03-13T15:01:40+01:00″ />
- <meta property=”bytedance:updated_time” content=”2022-03-13T15:01:40+01:00″ />
将代码放到标签中,帮助站点收录展示时间字段,有助于帮助站点优化落地页体验 · 请替换标签中的content字段值为真实的内容发布时间,时间格式:2022-03-13T15:01:40+01:00
字段解释:
published_time 内容发布时间
updated_time 内容更新时间
lrDate_time 内容最新回复时间
主题修改方法
在header.php中加入:
- <?php
- /**
- * 头条搜索:时间因子
- */
- if( is_single() ) {
- $pTime = get_the_time( 'U' );
- $uTime = get_the_modified_time( 'U' );
- $lTime = get_the_date( DATE_W3C );
- if( $pTime !== $uTime ){
- $lTime = get_the_modified_time( DATE_W3C );
- }?>
- <?php if(get_the_date( DATE_W3C )){?>
- <meta property="bytedance:published_time" content="<?php echo get_the_date( DATE_W3C );?>" />
- <?php }?>
- <?php if(get_the_modified_time( DATE_W3C )){?>
- <meta property="bytedance:lrDate_time" content="<?php echo get_the_modified_time( DATE_W3C );?>" />
- <?php }?>
- <meta property="bytedance:updated_time" content="<?php echo $lTime;?>" />
- <?php }?>
通过上面方法就可以完成在WordPress主题中增加头条搜索的“时间因子提交”功能了。