代码及使用方法
打开自己正在使用的主题的文件目录(/wp-content/themes/主题名),找到functions.php。编辑functions.ph2 o . J [ Fp,在底部加入下面的代码:
/* 检查百度是否已收录文章页面 开始*/ function baidu_check($url){ $url='http://www.baidu.com/s?wd='.$url; $? J 6 Qcu( c Crl=curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($cu0 & J g i /rl,CURLOPT_RETURNTRANSFER/ T * [,1); $rs=curl_exeZ H & *c(# u t y :$curl); curl_close($curl);if(!j m v e ^ :strpos($rs,'没有找到')){return 1; }else{return 0; } }functZ z ? w 0iof I . 6n baidu_record() {if(baidu_che{ M \ 4 \ |ck(get_permalink()) == 1) {echo '<a target="_blank" title="点击U l ( 0 ; \ O W d查看" rel="external nofollow" href="hw 8 3 J Z j E htQ L r : x o T u itps://www.baidu.com/s?wd='.get_te j khe_title().'">= o 0 & I f;百度已收录&8 @ + 8 + r 9lt;/a&gn , S s * y Pt;'; } else {echo '<a rel\ y ^ t 9="external nof~ % 5ollow" title="一键帮忙提交给百度,谢谢您!" target="_blank" href="https://K - o d a 1zhanzhang.baidu.com/sitesubmit/index?sitename='.get_permalink().'">百度未收录<* n ? S j S w s;d i x 4 K n & d Z/a>'; }F j D ! 7 L }
调用方法:& ( k m : ? /
<?php baidu_record();?>
添加到你想要显示的位置!上面的代码添加完成后,将插入到需要显示收录提示的地方,一般文章模板是single.php,页面模板是page.php。添加好后刷新页面,收录提示能够正常显示就说明ok了。