WordPress教程:不用插件怎么查看网站文章有没有被百度收录的方法
教程方法:
直接将下面的代码添加到当前主题的 functions.php 即可实现效果。
/* Plugin Name: Baidu-Accept Plugin URI: http://www.jiaoyiguo.com Description: 判断当前文章是否被百度收录,若没有被收录则可点击提交至百度,加速收录!(此插件在文章页面仅管理员可见) Version: 1.0 Author: Jovae Author URI: http://www.jiaoyiguo.com License: GPL */ 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; }
未收录显示效果演示截图:
已收录显示效果演示截图:
我的
足迹
投稿
反馈
客服
客服QQ:104****84 (点击直接对话)
客服电话:400****16(查看完整电话)
客服邮箱:service@liesan.com
管理仅处理交易投诉、举报、帐号、资金等平台使用问题;
商品问题请咨询各商品详情页面中显示的商家客服QQ。