2024年10月16日 建站教程
wordpress如何检测当前页面是否已被百度收录,下面web建站小编给大家简单介绍一下具体实现方法!
function baiduSL($url){
$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,'没有找到')){
return 1;
}else{
return 0;
}
}
add_filter( 'the_content', 'baidu_submit' );
function baidu_submit( $content ) {
if( is_single() && current_user_can( 'manage_options') )
if(baiduSL(get_permalink()) == 1)
echo '<p align=right><b><a target="_blank" title="点击查看" rel="external nofollow" href="https://www.baidu.com/s?wd='.get_the_title().'">此文章已被百度收录</a></b>(仅管理员可见)</p>';
else
$content="<p align=right><b><a style=color:red target=_blank href=https://zhanzhang.baidu.com/sitesubmit/index?sitename=".get_permalink().">百度未收录!点击此处一键提给百度交</a></b>(仅管理员可见)</p>".$content;
return $content;
}
本文链接:http://so.lmcjl.com/news/15522/