High end responsive website template

Responsive web design, open source code, permanent use, unlimited domain name, unlimited number of uses

ECS 2 folded

Baidu Xiongzhang Search Results Plot Code Transformation Practice

Bear's paw It provides high-quality image and text content producers with the right to plot search results, helps the site obtain a better display style of search results, and provides search users with a better browsing experience. For landing pages and resources whose image quality meets the requirements, the style of one picture and three pictures will be displayed in the search results.

 Baidu bear palm search results plot code transformation practical website operation page 1

The above case is the case of Baidu Mobile search results mapping, and it is three pictures, which is the most expected effect, so the next transformation is based on three pictures. Of course, after the transformation is completed, it is not mandatory to have three pictures for each content. If there are no three pictures in the text, the final realization is the effect of one picture. It can be said that it can meet everyone's transformation needs in an all-round way.

1、 Page code transformation

First of all, Baidu officials have made it clear that in order to achieve the mapping of search results, the page needs some code transformation, and Baidu also gives JSON-LD examples, as follows:

 Baidu bear palm search results plot code transformation practical website operation sheet 2

For those who know a little about the code, this code is not complicated, but we can't ignore that some SEOers are not very proficient in the code, so Kane will provide you with the final version of JSON-LD examples that can be directly added to their own pages according to his own transformation of the bear's paw.

2、 Example of JSON-LD for dream program page transformation

From the above JSON-LD example, we can see that @ id, appid, images and pubDate need to be changed. The detailed principle Kehu Network Not to mention here, the final JSON-LD example will be posted for you directly:

 Baidu bear palm search results plot code transformation practical website operation page 3

Put this code in the head of the source code template of the content page, that is, between<head></head>. Specifically, it is placed in the template file. The template file of a site varies. Some sites may be placed in the header file, usually named head.htm, or they may be placed in the detail page file, usually named article_article.htm.

3、 Example of JSON-LD for WordPress program page transformation

Also post the final JSON-LD example for everyone, which will take effect as long as it is directly pasted at the head of the content page. The code is as follows (please change the bear palm ID to your actual bear palm ID):

 Baidu bear palm search results plot code transformation practical website operation page 4

4、 Example of JSON-LD for Z-BlogPHP program page transformation

Z-BlogPHP is actually written in the same way as WordPress, except that the following code is separated. The php part is generally written in include.php, and the script part is generally added to the template file header.php (please modify the red part):

PHP part:

function mip_kh_thumbs2($as) { // Mip_kh is the subject or plug-in ID, please replace it with the actual ID

    global $zbp;

$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";

$content = $as->Content;

preg_match_all($pattern,$content,$matchContent);

$n = count($matchContent[1]);

if( $as->Metas->postimg ){

    $temp= $as->Metas->postimg;

}elseif(isset($matchContent[1][0])){

    if($n >= 3){

            $temp = $matchContent[1][0].' ","'.$ matchContent[1][1].' ","'.$ matchContent[1][2];

    }elseif($n >= 1){

        $temp = $matchContent[1][0];

    }

    } else {

        $temp = " https://kehu56.com/kehu/noimg.jpg " ; // The random picture when the article has no picture, please replace with the actual picture address

    }

    return $temp;

}

Script part:

<script type="application/ld+json">

{

    "@context": " https://ziyuan.baidu.com/contexts/cambrian.jsonld ",

    "@id": "{$article.Url}",

    "appid": " one thousand five hundred and ninety-nine trillion and five hundred and ninety-nine billion five hundred and forty-nine million one hundred and nine thousand and seven ", 

    "title": "{$article.Title}",    

    "images": ["{ mip_kh_thumbs2($article) }"],

    "description": "{preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Intro,'[nohtml]'),120)))}...",

    "pubDate": "{$article.Time('Y-m-d')}T{$article->Time('H:i:s')}"

}

</script>

5、 Picture quality requirements

Although we have completed the transformation, this does not mean that pictures will appear in the results, because Baidu has high requirements for the picture itself in addition to technical requirements for the picture:

 Baidu Bear Palm Search Results Plot Code Transformation Practice Website Operation Page 5

Other website programs can refer to the transformation methods of dream weaving program and WP program.

Related news

Website Style

contact us

thirteen billion nine hundred and twenty-two million one hundred and nine thousand five hundred and seventeen

seven hundred and forty-nine million eight hundred and forty-three thousand four hundred and eighteen

kehu56@126.com

:9:30-22:30

 QR code