5月31日百度上线“极光算法”,针对5月初发布的《百度搜索落地页时间因子规范》算是一个积极落地的行为
2018年5月底,百度搜索将上线极光算法,倡导各位资源方重视网站落地页时间规范。落地页时间因子是百度搜索判断网站收录、展示、排序结果的重要参考依据,为了让搜索用户获得更满意的搜索浏览体验,我们将给予符合落地页时间因子要求、且时效性较高的网页更多的收录和展现机会,同时对不符合的网站减少展现机会。
百度搜索已推出百度搜索落地页时间因子规范,开放对落地页时间因子的提取规范,各位资源方可参考规范,自行优化;另外对已发现的时间因子作弊行为,也将严厉打击,绝不手软。
说白了,其实对收录会有间接的好处,感觉更多的是给予原创内容的保护。
具体规则规范直接百度《百度搜索落地页时间因子规范》
下面直接放JSON-LD 结构化数据格式代码:
<?php
if(is_home()){
echo '<script type="application/ld+json">{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "'.get_bloginfo('url').'",
"appid": "1583638885552229",
"title": "'.wp_title('',0).'",
"images": ["'.fanly_post_imgs().'"],
"pubDate": "'.get_the_time('Y-m-d\TH:i:s').'"
"upDate": "'.get_the_modified_time('Y-m-d\TH:i:s').'"
"data": {
"Webpage": {
"headline": "'.wp_title('',0).'",
"pcUrl": "'.get_bloginfo('url').'",
"wapUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_bloginfo('url')).'",
"mipUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_bloginfo('url')).'",
"fromSrc": "复合材料网"
"datePublished": "'.get_the_time('Y-m-d\TH:i:s').'"
}
}
}</script>
';}else
if(is_single()||is_page()){
echo '<script type="application/ld+json">{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "'.get_the_permalink().'",
"appid": "1583638885552229",
"title": "'.get_the_title().'",
"images": ["'.fanly_post_imgs().'"],
"description": "'.fanly_excerpt().'",
"pubDate": "'.get_the_time('Y-m-d\TH:i:s').'"
"upDate": "'.get_the_modified_time('Y-m-d\TH:i:s').'"
"data": {
"Webpage": {
"headline": "'.get_the_title().'",
"pcUrl": "'.get_the_permalink().'",
"wapUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_permalink()).'",
"mipUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_permalink()).'",
"fromSrc": "复合材料网"
"datePublished": "'.get_the_time('Y-m-d\TH:i:s').'"
}
}
}</script>
';}else
if(is_tax() || is_tag() || is_category()){
echo '<script type="application/ld+json">{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "'.get_term_link( $term, $term->taxonomy ).'",
"appid": "1583638885552229",
"title": "'.wp_title('',0).'",
"images": ["'.fanly_post_imgs().'"],
"pubDate": "'.get_the_time('Y-m-d\TH:i:s').'"
"upDate": "'.get_the_modified_time('Y-m-d\TH:i:s').'"
"data": {
"Webpage": {
"headline": "'.wp_title('',0).'",
"pcUrl": "'.get_term_link( $term, $term->taxonomy ).'",
"wapUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_term_link( $term, $term->taxonomy )).'",
"mipUrl": "'.str_replace('www.frpplus.com','m.frpplus.com',get_term_link( $term, $term->taxonomy )).'",
"fromSrc": "复合材料网"
"datePublished": "'.get_the_time('Y-m-d\TH:i:s').'"
}
}
}</script>
';}
//获取文章中的图 last update 2018/01/22
function fanly_post_imgs(){
global $post;
$src = '';
$content = $post->post_content;
preg_match_all('/<img .*?src=[\"|\'](.+?)[\"|\'].*?>/', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n >= 3){
$src = $strResult[1][0].'","'.$strResult[1][1].'","'.$strResult[1][2];
}elseif($n >= 1){
$src = $strResult[1][0];
}
return $src;
}
//获取文章/页面摘要
function fanly_excerpt($len=220){
if ( is_single() || is_page() ){
global $post;
if ($post->post_excerpt) {
$excerpt = $post->post_excerpt;
} else {
if(preg_match('/<p>(.*)<\/p>/iU',trim(strip_tags($post->post_content,"<p>")),$result)){
$post_content = $result['1'];
} else {
$post_content_r = explode("\n",trim(strip_tags($post->post_content)));
$post_content = $post_content_r['0'];
}
$excerpt = preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,0}'.'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s','$1',$post_content);
}
return str_replace(array("\r\n", "\r", "\n"), "", $excerpt);
}
}
?>
主要基于泪雪博客的代码,代码不是很严谨,本人不是科班出生,凑个热闹而已,期待更好的代码。