wordpress[WP]文章搜索结果自动提交到百度代码

1到百度资源平台提交网址申请主动提交token的网址

2在wp后台外观主题编辑处找到search.php文件修改编辑

3添加自动提交代码

<?php if ( have_posts() ){

$api = ‘http://data.zz.baidu.com/urls?site=www.xxx.com&token=xxxxx’;
//echo ‘11111111111’;
$pushurl = ‘http://’.$_SERVER[‘HTTP_HOST’].’/?s=’.get_search_query();
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $pushurl,
CURLOPT_HTTPHEADER => array(‘Content-Type: text/plain’),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$result_j=json_decode($result);

}

4当用户在网站前台搜索时就可以自动提交到百度了

5百度对于用户搜索结果比较重视,所以提交对seo有益处。