在绑定阶段,可以选择使用当前熊掌号。也可以绑定其它熊掌号,输入未绑定过的熊掌号名称即可,熊掌号会自动完成转换。
选择想绑定的网站(注意:网站的内容要符合移动的浏览要求,纯PC网站无法申请),点击发送验证码,输入发送熊掌号使用的手机号会收到验证码消息,点击确定即可。
完成以上步骤后,网站与熊掌号绑定就完成了。
WordPress添加熊掌号的json_id结构化数据代码如下:
PHP代码,用于获取文章摘要内容,代码添加在当前主题functions.php中
<?php//获取文章/页面摘要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)
}}?>
json_id数据,添加在head头部中:
<script type="application/ld+json">{"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "<?php the_permalink() ?>",
"appid": "这里请填写熊掌号ID",
"title": "<?php the_title() ?>",
"images": ["<?php echo catch_that_image() ?>"],
"description": "<?php echo fanly_excerpt()?>",
"pubDate": "<?php echo get_the_time('Y-m-d\TH:i:s')?>",
}</script>
appid就是熊掌号ID,自己修改一下即可。
以上代码来源于泪雪博客:网页链接 版权归属原作者
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)