WordPress发布文章如何主动推送到百度快速收录
            
            
            
                    
        
        
        
        
            
        
                             
            
                
 
 | 
 
| 很简单,只需要在主题的function.php文件里面的自定义位置添加如下代码: 
 后续发问题就会自动推送到百度快速收录。复制代码/** WordPress 发布文章主动推送到百度快速收录**/
 
if(!function_exists('Baidu_Submit')){
function Baidu_Submit($post_ID) {
//已成功推送的文章不再推送
if(get_post_meta($post_ID,'Baidusubmit',true) == 1) return;
$url = get_permalink($post_ID);
$api = 'http://data.zz.baidu.com/urls?site=https://www.XXXXX/&token=XXXXXXXXXXXX&type=daily';替换为您的自己的连接
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $url,
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result = json_decode($result);
if( $result->success_daily ){
add_post_meta($post_ID, 'Baidusubmit', 1, true);
}
}
add_action('publish_post', 'Baidu_Submit', 0);
}
前提是百度已经开通了该功能。
 
 | 
 | 
|  | 
|
|  | 
|  |