• 武汉加油,中国加油,免费投稿邮箱 creust@creust.com,vps,服务器,vps 推荐

wordpress更新文章实时推送到百度新方案

VPS推荐 创启云客 6个月前 (06-16) 1932次浏览 已收录 0个评论 扫描二维码

百度最近在站长平台里发布了公告,决定停用现在的百度 sitemap1.0,使用了新的推送方式,也就是今天的主角:主动推送(实时)。
wordpress更新文章实时推送到百度新方案

那么先前安装的wordpress插件也可以卸载了,申请了百度实时推送的接口

首先给出申请地址:http://zhanzhang.baidu.com/linksubmit/ 大家前去了解下百度新的主动推送机制!

然后,结合本站团队成员维维大神的研究测试,且免去安装WP BaiDu Submit插件的实现了 wordpress 更新文章实时推送到百度新策略!

将下面的代码添加到你主题的 functions.php 中去,并替换相关API

<span class="com">/*
 百度实时推送
*/</span>
<span class="kwd">function</span><span class="pln"> mee_post_baidu</span><span class="pun">(</span><span class="pln">$post_id</span><span class="pun">,</span><span class="pln">$post</span><span class="pun">){</span><span class="pln">
$PostUrl </span><span class="pun">=</span><span class="pln"> get_permalink</span><span class="pun">(</span><span class="pln">$post_id</span><span class="pun">);</span><span class="pln">
$urls</span><span class="pun">=</span><span class="pln">array</span><span class="pun">(</span><span class="pln">$PostUrl</span><span class="pun">);</span><span class="pln">
$api </span><span class="pun">=</span> <span class="str">'你的 api 调用地址'</span><span class="pun">;</span><span class="pln">
$ch </span><span class="pun">=</span><span class="pln"> curl_init</span><span class="pun">();</span><span class="com">//</span><strong><span class="com"><a href="https://blog.creust.com/tag/261" title="查看更多关于主机的文章" target="_blank">主机</a></span></strong><span class="com">需要支持 curl</span><span class="pln">
$options </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
CURLOPT_URL </span><span class="pun">=&</span><span class="pln">gt</span><span class="pun">;</span><span class="pln"> $api</span><span class="pun">,</span><span class="pln">
CURLOPT_POST </span><span class="pun">=&</span><span class="pln">gt</span><span class="pun">;</span> <span class="kwd">true</span><span class="pun">,</span><span class="pln">
CURLOPT_RETURNTRANSFER </span><span class="pun">=&</span><span class="pln">gt</span><span class="pun">;</span> <span class="kwd">true</span><span class="pun">,</span><span class="pln">
CURLOPT_POSTFIELDS </span><span class="pun">=&</span><span class="pln">gt</span><span class="pun">;</span><span class="pln"> implode</span><span class="pun">(</span><span class="str">"\n"</span><span class="pun">,</span><span class="pln"> $urls</span><span class="pun">),</span><span class="pln">
CURLOPT_HTTPHEADER </span><span class="pun">=&</span><span class="pln">gt</span><span class="pun">;</span><span class="pln"> array</span><span class="pun">(</span><span class="str">'Content-Type: text/plain'</span><span class="pun">),</span>
<span class="pun">);</span><span class="pln">
curl_setopt_array</span><span class="pun">(</span><span class="pln">$ch</span><span class="pun">,</span><span class="pln"> $options</span><span class="pun">);</span><span class="pln">
curl_exec</span><span class="pun">(</span><span class="pln">$ch</span><span class="pun">);</span>
<span class="pun">}</span><span class="pln">
add_action</span><span class="pun">(</span><span class="str">'publish_post'</span><span class="pun">,</span> <span class="str">'mee_post_baidu'</span><span class="pun">);</span>

替换上面的 api 地址为你自己的即可,这样的方法是最简单明了的,如果不会操作的朋友,还是可以尝试下载安装WP BaiDu Submit插件的,至于插件的设置嘛。。还是很小白化的,这里就不叙述了,在这,感谢百度,感谢团队维维的贡献!


创启云客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:wordpress更新文章实时推送到百度新方案
喜欢 (1)
[13738388032@qq.com]
分享 (0)
创启云客
关于作者:
vps,服务器,云服务器,第三方支付,免费CDN,免费pos,Hexo,pos机,支付圈,免费vps,Discuz,emlog,主题,日本vps,国外服务器,美国vps,香港vps,便宜vps,便宜服务器,vps服务器
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址