检查wordpress文章页面显示是否已被百度收录的方法

将以面代码添加到当前主题的 functions.php 下即可:
/*
判断当前文章是否被百度收录,若没有被收录则可点击提交至百度,加速收录!(此插件在文章页面仅管理员可见) 
*/
function d4v($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(d4v(get_permalink()) == 1) 
			$content="<p align=right>百度已收录(仅管理员可见)</p>".$content; 
		else 
			$content="<p align=right><b><a style=color:red target=_blank href=http://zhanzhang.baidu.com/sitesubmit/index?sitename=".get_permalink().">百度未收录!点击此处提交</a></b>(仅管理员可见)</p>".$content;  
		return $content;
	}

检查wordpress文章页面显示是否已被百度收录的方法

本文来自投稿,不代表科技代码立场,如若转载,请注明出处https://www.cwhello.com/3901.html

如有侵犯您的合法权益请发邮件951076433@qq.com联系删除

(0)
上一篇 2017年11月30日 09:24
下一篇 2017年11月30日 14:04

相关推荐

联系我们

QQ:951076433

在线咨询:点击这里给我发消息邮件:951076433@qq.com工作时间:周一至周五,9:30-18:30,节假日休息