[WordPress Tutorial] Process record of accessing Baidu Bear Palm to the robin Begin theme

 Watson Blog July 15, 2018 00:15:16 WordPress comment three hundred and thirty-four Reading mode

[WordPress Tutorial] Connect the robin Begin theme to the Baidu bear palm process record, add the canonical tag, JSON_LD data, attention code, etc.

Step 1: Add canonical tag

Official introduction:

The content of href is required to be the address of the corresponding PC page of MIP page or H5 page; If there is no PC page, fill in the current page address.

  1. <link rel= "canonical"  href= "http(s)://xxx" />

 

Operation record:

Find the corresponding header.php file and add the following code after<head>:

  1. <!-- Baidu bear palm adds canonical label -->
  2. <link rel= "canonical"  href= "<?php the_permalink() ?> " />

 

Step 2: Add JSON_LD data

Official introduction:

The following code is an example of JSON-LD:

  1. <script type= "application/ld+json" >
  2.     {
  3.          "@context" " https://ziyuan.baidu.com/contexts/cambrian.jsonld " ,
  4.          "@id" " https://ziyuan.baidu.com/college/articleinfo?id=1464 " ,
  5.          "appid" "1582926961485115" ,
  6.          "title" "Baidu Mobile Search Landing Page Experience White Paper - Advertising 2.0" ,
  7.          "images" : [
  8.              " https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png " ,
  9.              " https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png " ,
  10.              " https://m.baidu.com/static/index/plus/plus_logo.png "
  11.             ],
  12.          "description" "High quality and reasonable advertising, as a supplement to information, is widely liked by users. At the beginning of 2017, Baidu User Experience Department conducted a satisfaction survey on users, and found that many malicious and low-quality advertising seriously damaged users' search experience." ,
  13.          "pubDate" "2017-06-15T08:00:01"
  14.     }
  15. </script>

Operation record:

Also add the following code after the<head>in the header.php file. I add it after the canonical tag:

  1. <!-- Baidu bear palm adds JSON_LD data -->
  2. <script type= "application/ld+json" >
  3.     {
  4.          "@context" " https://ziyuan.baidu.com/contexts/cambrian.jsonld " ,
  5.          "@id" "<?php the_permalink() ?> " ,
  6.          "appid" "1577487331441713" ,
  7.          "title" "<?php the_title();  ?> " ,
  8.          "images" : [
  9.              " http://wosn.net/wp-content/themes/begin/img/favicon.png "
  10.             ],
  11.          "description" "<?php if (has_excerpt()){ ?>
  12.  <? php the_excerpt() ?>
  13.  <? php } else { echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 120," ... "); } ?>" ,
  14.          "pubDate" "<?php echo get_the_date() .  'T'.  get_the_time('H:i:s');  ?> "
  15.     }
  16. </script>

Step 3: Add bear paw ID declaration

Official introduction:

  1. <script src= "//msite.baidu.com/sdk/c.js?appid=1582926961485115" ></script>

Operation record

Add code in front of the page</head>tag, or continue to add code after the above two steps, without modification, just add the code provided by Baidu directly.

Part 4: Add the code of focus function

Official introduction:

Add the bar to be displayed (only 2 bars can be added and will be reviewed later)

Ceiling bar

<script>cambrian.render('head')</script>

Add code after the page<body>tag

Inter paragraph bar

<script>cambrian.render('body')</script>

Add code between page paragraphs

Bottom bar

<script>cambrian.render('tail')</script>

Add code at the end of the page article

Note: The above three bars do not reserve left and right margins in style. If the page itself does not set margins, it is recommended to use the following method. Where padding left and padding right are margin attributes, which can be modified as required.

  1. <div style= "padding-left: 17px; padding-right: 17px;" >
  2. Corresponding bar code
  3. </div>

Operation record:

I tried all three. After comparison, I still found that the bar at the bottom is pretty good. I put it at the bottom of the article, found the content.php of the theme file, and added the following code below line 86:

  1. <div  class = "single-content" >
  2.  <? php  if  ( has_excerpt() ) { ?><span  class = "abstract" ><fieldset><legend><? Php_e ('summary ',' leiben ');  ?></ legend><?php the_excerpt() ?>< div  class = "clear" ></div></fieldset></span><? php }?>
  3.  <? php get_template_part('ad/ads', 'single');  ?>
  4.  <? php the_content();  ?>
  5.  <script>cambrian.render('tail')</script><!-- Add bear paw focus function code - bottom bar -->
  6.  </div>

Finally, the renderings are as follows:

 [WordPress Tutorial] Process record of accessing Baidu Bear Palm to the robin Begin theme

Original link: http://www.tenanji.cn/archives/104.html

 Watson Blog
  • This article is written by Published on July 15, 2018 00:15:16
  • This article is collected and sorted by the website of Mutual Benefit, and the email address for problem feedback is: wosnnet@foxmail.com , please keep the link of this article for reprinting: https://wosn.net/1306.html

Comment