当前位置:首页 >正文

WordPress怎么快速实现熊掌号结构化和绑定百度熊掌号

百度: 已收录 | 发布日期: 2018-10-23 0:30:57
pos机流量卡
pos机流量卡

wordpress怎么快速实现熊掌号结构化和绑定百度熊掌号,大家应该在绑定熊掌号的时候出现很多错误,今天卡卡哥带大家一起来了解是什么原因导致出现这些错误

出现比较多的错误类型有那些啦?我们首先需要知道有那些事错误,这个是坚决完问题的截图大家可以看看

熊掌号校验成功

一、h5校验不通过

二、不符合json-ld格式让商户(共1处错误)

三、canonical校验不通过

一般都是这三个错误那么解决方法是什么?

下面我们来说第一种解决方法是超级简单的直接填写一段代码即可

<script src=”//msite.baidu.com/sdk/c.js?appid=这里写你自己的熊掌号id”></script>

wordpress怎么快速实现熊掌号结构化和绑定百度熊掌号

然后第二种错误的解决方法这个就要稍微麻烦一点了,但是也是可以使用代码解决的,下面看代码

首先把下面的代码粘贴到函数模板functions.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);


//优先获取文章中的三张图,否则依次获取自定义图片/特色缩略图/文章首图 last update 2017/11/23
function fanly_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;

wordpress怎么快速实现熊掌号结构化和绑定百度熊掌号

上面的代码粘贴好了上传你的服务器或ftp都行,然后就是修改至之前的错误连接代码

<?php
if(is_single()){
echo ‘<script type=”application/ld+json”>{
“@context”: “https://ziyuan.baidu.com/contexts/cambrian.jsonld”,
“@id”: “‘.get_the_permalink().'”,
“appid”: “1604299687196075”,
“title”: “‘.get_the_title().'”,
“images”: [“‘.fanly_post_imgs().'”],
“description”: “‘.fanly_excerpt().'”,
“pubdate”: “‘.get_the_time(‘y-m-d\th:i:s’).'”
</script>
‘;
?>

把上面的代码粘贴到你的header模板里面,然后再把之前的错误代码替换一下,这里if(is_single())的代码判断了一下是不是文章页面只会在文章页面显示。

下面还有就是最后一种错误解决方法跟第一种类似,直接一串小代码即可解决

<link rel=”canonical” href=”<?php the_permalink() ?>”/>

wordpress怎么快速实现熊掌号结构化和绑定百度熊掌号

当然上面的方法只有针对的是wprdpress的网站才会有效。

对于WordPress怎么快速实现熊掌号结构化和绑定百度熊掌号解答就到这里了,大家在使用pos机刷卡、pos机办理、pos机使用等等问题,上面有不明白的都可以加我微信(chengzhi369),使用pos机一定要在正规渠道办理,这样子使用才会更加的安全可靠,有保障。

版权声明:本文由作者:卡卡哥 原创,不允许转载,否则必追究法律责任,谢谢配合!!本文链接:https://www.chinahzx.cn/3596.html
本文标签: , ,


pos机免费办理-微信:170-025-66688