1.在Wordpress下编辑functions.php文件在“?>”之前添加如下代码
//添加百度是否收录功能 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 '<a target="_blank" title="点击查看" rel="external nofollow" href="https://www.baidu.com/s?wd='.get_the_title().'">百度已收录</a>'; } else { echo '<a style="color:red;" rel="external nofollow" title="点击提交,谢谢您!" target="_blank" href="https://zhanzhang.baidu.com/sitesubmit/index?sitename='.get_permalink().'">百度未收录</a>'; } }
2.然后在需要在Wordpress显示的地方添加如下代码
<span class="item"><?php baidu_record(); ?></span>

关注公众号『窗外天空』
获取更多建站运营运维新知!互联网创业、前沿技术......
最新评论
感谢分享,谢谢站长!!@天天下载
求同型号
能别用城通吗,缺钱缺这样啊
你好,请问有华硕ac68U可以使用的版本吗
xiaomi mini 是什么架构阿 是mipsel_24kc架构ma