效果预览

方法/步骤
一、将以下代码添加至 functions.php;
//判断文章是否被百度收录
function baidu_check($url){
global $wpdb;
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
$baidu_record = get_post_meta($post_id,'baidu_record',true);
if( $baidu_record != 1){
$url='http://www.baidu.com/s?wd='.$url;
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$rs=curl_exec($curl);
curl_close($curl);
if(!strpos($rs,'没有找到')){
if( $baidu_record == 0){
update_post_meta($post_id, 'baidu_record', 1);
} else {
add_post_meta($post_id, 'baidu_record', 1, true);
}
return 1;
} else {
if( $baidu_record == false){
add_post_meta($post_id, 'baidu_record', 0, true);
}
return 0;
}
} else {
return 1;
}
}
function baidu_record() {
if(baidu_check(get_permalink()) == 1) {
echo '<a target="_blank" title="点击查看收录情况" rel="external nofollow" href="http://www.baidu.com/s?wd='.get_the_title().'"><span class="but c-yellow"><i class="fa fa-paw" aria-hidden="true"></i>百度已收录</span></a>';
} else {
echo '<a style="color:red; rel="external nofollow" title="一键帮忙提交给百度,谢谢您!" target="_blank" href="http://zhanzhang.baidu.com/sitesubmit/index?sitename='.get_permalink().'"><span class="but c-grey"><svg class="icon" aria-hidden="true"><use xlink:href="#io-baidu1"></use></svg>百度未收录</span></a>';
}
}二、以下代码添加至自己主题页面文件适当位置,不同主题文件有所不同,子比主题在 /zibll/inc/functions/zib-single.php 文件,大概在300行左右,搜索下面代码放在下面即可。
<div class="article-content">
<!--百度检测收录按钮命令-->
<?php echo ' '; baidu_record(); ?>
<!--百度检测收录按钮命令-->本站除原创内容,其余内容均收集自互联网,仅限用于学习和研究目的,本站不对其内容的合法性、可用性承担任何责任。本站禁止以任何形式发布或转载任何违法相关信息,若您发现请立即向站长举报;用户投稿一切资源内容不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
如有版权内容,其版权均归原作者所有,本站虽力求保存原有版权信息,但因众多资源经多次转载,已无法确定其真实来源,故敬请原作者谅解!为尊重作者劳动成果,请购买正版支持作者,谢谢!若您对「HULIKU.COM」所载资源作品版权归属存有异议,请发送邮箱:ihuliku@qq.com 进行处理。
本站资源文件大多存储至云盘,如您发现图片或链接失效,请联系站长或作者,我们将及时进行更新。资源都是经过站长或作者收集测试优化后进行发布分享。如若转载请在贵站文内以超链形式注明狐狸库文章出处,谢谢合作!












![WordPress子比主题美化教程合集[2023/04/17]-狐狸库](https://huliku.com/pic/2023032607024935.png)
![狐狸库自定义子比主题底部footer页脚美化(自适应)[06.26]更新-狐狸库](https://huliku.com/pic/2023062610013835.png)






















请登录后查看评论内容