WordPress百度快速收录API提交代码SEO优化

.WordPress 百度快速收录 API 提交代码(方法:将以下代码添加到你的 WordPress 当前使用的主题的 functions.php 文件最下面,记得添加自己的API 接口地址。)//WordPress 百度快速收录 API 提交代码

//新的百度快速调用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 = ‘GUwI6uKrTpu1q0T2’;//快速收录推送接口
$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 避免重复提交
}
}

未经允许不得转载:萌萌guo angline - Apprentissage » WordPress百度快速收录API提交代码SEO优化

赞 (1) 打赏

评论 0

Protected with IP Blacklist CloudIP Blacklist Cloud

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

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏