時(shí)間:2023-08-15 08:27:02 | 來源:網(wǎng)站運(yùn)營
時(shí)間:2023-08-15 08:27:02 來源:網(wǎng)站運(yùn)營
寫給小白的Wordpress百度熊掌號快速申請改造使用指南:自從百度站長平臺升級為百度搜索資源平臺之后,傳統(tǒng)的網(wǎng)站收錄提交方式都發(fā)生了很大的變革,尤其是2017年百度推出熊掌號之后,很多站長都處于迷茫的觀望中。<!--熊掌號--><script src="//msite.baidu.com/sdk/c.js?appid=***************"></script><?php if(is_single()){?><link rel="canonical" href="<?php echo get_permalink($post->ID);?>" /><?php } ?><?phpif(is_single()){echo '<script type="application/ld+json">{"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld","@id": "'.get_the_permalink().'","appid": "1588743926794531","title": "'.get_the_title().'","images": ["'.aure_post_imgs().'"],"description": "'.aure_excerpt().'","pubDate": "'.get_the_time('Y-m-d/TH:i:s').'"}</script>';};?>
其中******號的id請查閱下圖紅色部分百度熊掌號JSON_LD配置代碼自動(dòng)分配的appid號碼。//熊掌號Json_LD數(shù)據(jù)/*獲取文章/頁面摘要*/function aure_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);}}/*優(yōu)先獲取文章中的三張圖,否則依次獲取自定義圖片/特色縮略圖/文章首圖*/ function aure_post_imgs(){global $post;$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];}else{if( $values = get_post_custom_values("thumb") ) {//輸出自定義域圖片地址$values = get_post_custom_values("thumb");$src = $values [0];} elseif( has_post_thumbnail() ){//如果有特色縮略圖,則輸出縮略圖地址$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'full');$src = $thumbnail_src [0];} else {//文章中獲取if($n > 0){ // 提取首圖$src = $strResult[1][0];} }}return $src;}
最后進(jìn)行熊掌號改造后的校驗(yàn)工作,我們打開自己網(wǎng)站的某一篇文章頁面,將該文章鏈接地址填入熊掌號校驗(yàn)頁面。再鼠標(biāo)右鍵選擇查看該文章頁面的網(wǎng)頁源代碼,復(fù)制粘貼到熊掌號校驗(yàn)頁面下方代碼校驗(yàn)區(qū)。關(guān)鍵詞:申請,改造,指南,使用,熊掌
客戶&案例
營銷資訊
關(guān)于我們
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。