本文最后更新于 2022-10-14,已超过 365 天未更新,内容可能已失效。
将以下代码添加到你的 WordPress 当前使用的主题的 functions.php 文件合适地方,并且将代码中的 API 地址修改替换为你在百度搜索资源平台的快速收录的 API 接口地址即可。
代码:
//WordPress 百度快速收录 API 提交代码
add_action('save_post', 'fanly_baidu_dailysubmit', 10, 3);
function fanly_baidu_dailysubmit($post_id, $post, $update){
if($post->post_status != 'publish' || get_post_meta($post_id,'Fanly_Submit',true)=='OK') return;
$api = 'http://data.zz.baidu.com/urls?site=https://yehes.com/&token=c4LbbowRJZmedaam&type=daily';//快速收录复制过来
$response = wp_remote_post($api, array(
'headers' => array('Accept-Encoding'=>'','Content-Type'=>'text/plain'),
'sslverify' => false,
'blocking' => false,
'body' => get_permalink($post_id)
));
if ( !is_wp_error( $response ) ) {
$res = json_decode($response['body'], true);
if($res['success_daily']==1)update_post_meta($post_id, 'Fanly_Submit', 'OK');// OK 避免重复提交
}
}
快速收录使用说明
- 快速收录仅限于提交移动端页面及移动端自适应页面。
- 快速收录工具可以向百度搜索主动推送资源,缩短爬虫发现网站链接的时间,对于高实效性内容推荐使用快速收录工具,实时向搜索推送资源。
- 资源不符合移动资源标准,依然会占用配额,请您谨慎选择提交类型。
- 如果网站已通过 HTTPS 认证工具验证为 HTTPS 网站,请确保所提交链接的协议头为 HTTPS。
除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。
![riplus子主题-子佩主题2.0.0[送ripro子主题一份]](https://www.helloimg.com/images/2021/01/09/8fb95be2b7c89307dc09f4fb7fc737dc3111a638f80835df.png)



登录后即可发表评论
全部评论 (0)