Yang Zeyi: Actively push your website content to Baidu

Source: Internet
Author: User

The day before yesterday we talked about the content of your website automatically pushed to Baidu, today, said, the site content initiative to push to Baidu.

Auto push that is super simple, add the auto push code to the bottom of the page (footer.php).

Proactive push is more complicated than automatic push, fortunately, our theme of the developer, has already put this function in, just need to set the parameters in the background can be.

Method: Background--appearance--Theme options--seo Settings--enable the article actively push to Baidu--input Baidu actively push the token value can be.

Baidu Initiative Push settings

So where does this value get? Open the Baidu Resource Center, add website can.

Portal: Https://ziyuan.baidu.com/linksubmit/index

Get Baidu Token value

In fact, the developer of this template, not only can be submitted to Baidu, can also be directly configured in the background Baidu Bear Paw, because my other website has the Bear Paw number, this site did not apply the Bear paw number.

Of course, if your theme developer does not have this configuration, write one yourself, insert the following code into the theme function file (functions.php) can be:

  1. /* Baidu active Push code start */

  2. if (!function_exists (' Baidu_submit ')) {

  3. function Baidu_submit ($post _id) {

  4. $WEB _token = '123456'; //Here please replace your website Baidu initiative to push the token value

  5. $WEB _domain = get_option (' home ');

  6. //The articles that have been successfully pushed are no longer pushed

  7. if(Get_post_meta ($post _id, ' Baidusubmit ',true) ==1)return;

  8. $url = Get_permalink ($post _id);

  9. $api = ' http://data.zz.baidu.com/urls?site= '. $WEB _domain. ' &token= '. $WEB _token;

  10. $request = new wp_http;

  11. $result = $request->request ($api, Array (' method ' = ' POST ', ' body ' = = $url, ' headers ' = ' content-type:te Xt/plain '));

  12. $result = Json_decode ($result [' body '],true);

  13. //If push succeeds then add custom column Baidusubmit in the article, with a value of 1

  14. if (Array_key_exists (' success ', $result)) {

  15. Add_post_meta ($post _id, ' Baidusubmit ', 1, true);

  16. }

  17. }

  18. Add_action (' Publish_post ', ' baidu_submit ', 0);

  19. }

  20. /* Baidu active Push code end */

Because my website has been actively pushed in the background configuration number, you can now view the relevant data of the Baidu Resource Center:

Baidu Push Data

Well, the article initiative to Baidu's tutorial will be here has been finished, so far, the initiative push + automatic push +sitemap 3 ways (manual submission Needless to say it), has all finished, finished these work, Baidu included your article content will be faster.

Source: Ze Industry construction Station Network

This article by Tze Industry original, published in 51CTO blog



Yang Zeyi: Actively push your website content to Baidu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.