By using this site, you agree to the Privacy Policy and Terms of Use.
接受
智诚云集
  • 首页
  • 互联网
  • 分享
  • 记录
  • 互联网
    • Blog Index
    • Search Page
    • 404 Page
  • 联系
阅读: 免插件WordPress文章加入百度是否收录按钮
SUBSCRIBE
智诚云集智诚云集
Font ResizerAa
  • 云服务器推荐
  • 腾讯云
  • 阿里云
  • 京东云
Search
  • Home
  • Home
  • Blog
  • Blog
  • Categories
    • Technology
    • Travel
    • Lifestyle
    • Market
    • Innovate
    • Insurance
  • Categories
    • Technology
    • Travel
    • Lifestyle
    • Market
    • Innovate
    • Insurance
  • Bookmarks
  • Bookmarks
  • More Foxiz
    • Blog Index
    • Sitemap
  • More Foxiz
    • Blog Index
    • Sitemap
  • Contact
  • Contact
Have an existing account? 登录
关注我们
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
分享

免插件WordPress文章加入百度是否收录按钮

智诚云集 - Xyok.Cn
最后更新: 2025年12月6日 下午9:15
智诚云集 - Xyok.Cn
9 Min Read
分享
分享

无意中逛WordPress大佬的博客发现个比较实用的小工具,通过简短代码实现文章快速查询和显示是否收录的代码,然后就记录了以下并且署名大佬的名称和源地址。
找到当前主题目录下的functions.php文件加入以下代码:

/**
 * WordPress 显示百度是否收录功能(自定义栏目优化版)
 * https://zhang.ge/4617.html
 * DIY By 张戈博客 
**/
function baidu_check($url,$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,'没有找到该URL。您可以直接访问') && !strpos($rs,'很抱歉,没有找到与') ){
            update_post_meta($post_id, 'baidu_record', 1) || add_post_meta($post_id, 'baidu_record', 1, true);
            return 1;
        } else {
            return 0;
        }
    } else {
       return 1;
    }
}
function baidu_record() {
    global $wpdb;
    $post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
    if(baidu_check(get_permalink($post_id), $post_id ) == 1) {
        echo '百度已收录';
   } else {
        echo '百度未收录';
   }
}

然后在当前主题文章模板(content.php 一般情况是这个名字的文件)合适位置加入以下代码

<?php baidu_record(); ?>
标签:baidufunctionsWordPress主题百度收录
分享这篇文章
Facebook Email Copy Link Print
By智诚云集 - Xyok.Cn
关注:
分销:阿里云、腾讯云、百度云、GoDaddy、景安云、Linode云服务器产品。
上一篇 淘宝服务类型网店遇到的奇葩买家汇总
下一篇 wordpress用nofollow属性减少页面权重流失集中内页权重的方式

You Might Also Like

分享

抖音 bilibili 微博 秒拍 Facebook Youtube短视频ParseVideo解析播放下载

在qq群中看到一个不…

4 Min Read
分享

[天猫维权]无赖企业上海沪工集团可耻销售行为

维权对象: 天猫网店…

7 Min Read
分享

steam登录csgo国际服获取CSGO2测试资格

《反恐精英2》(《C…

2 Min Read
分享

如何查看网卡以及网络设备是否支持100M以上宽带(千兆)

今天由于手残导致网络…

10 Min Read
智诚云集智诚云集
关注我们
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?