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

Auth:猫饭       Date:2021/11/14       Cat:代码       Word:共561字       Views:32

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

wordpress[WP]文章搜索结果自动提交到百度代码 - 第1张图片

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

wordpress[WP]文章搜索结果自动提交到百度代码 - 第2张图片wordpress[WP]文章搜索结果自动提交到百度代码 - 第3张图片

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有益处。

除非注明,猫饭文章均为原创,本文地址 https://maofun.com/1970.html,转载请以链接形式注明出处。

作者: 简介:

《wordpress[WP]文章搜索结果自动提交到百度代码》留言数:0

发表留言