New version of WordPress Baidu actively pushes code

» WordPress » New version of WordPress Baidu actively pushes code

Baidu takes the initiative to push high-quality content directly to Baidu to speed up the collection

WordPress新版百度主动推送代码-极客公园

preface

Some time ago, Baidu sent a large number of sitemap permissions, and can push its own new articles directly to Baidu. Now Yunluo shares its WordPress code, which is temporarily effective.

function code

Add code to the theme functions.php file

 function _baidu_tuisong($post_ID){ global $post; If (function_exists ('curl_init ')) {//Judge whether curl extension is enabled $_tuisong_site='Enter your domain name again, such as. me, without http://'; $_tuisong_token='Enter your key here '; if( empty($post_ID) || empty($_tuisong_site) || empty($_tuisong_token) ) return; $api = ' http://data.zz.baidu.com/urls?site= '.$_ Tuisong_site. '&token='. $_tuisong_token;//Baidu's official API If ($post ->post_status="publish") {//Only published articles $url = get_permalink($post_ID); $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); } } } add_action('publish_post', '_baidu_tuisong', 0);

Change the content into your own

Precautions

Using Baidu's active push is equivalent to bypassing other mechanisms and directly pushing content to Baidu. But if you don't push high-quality content every time, Baidu Spider will even punish the website. So if you use this, try not to send non nutritious content, but it is an extension of this code, and you can also add a custom field to the article, Use fields to determine whether this article is pushed. Of course, it will not be expanded here

Postscript

--End--

Post reply

Your email address will not be disclosed. Required items have been used * tagging

26 Replies to "WordPress New Version Baidu Active Push Code"