We should have some knowledge about adaptation, but we have been thinking about how to display different advertisements on the PC side and mobile side. Some time ago, because of work, we have been busy, and gradually forget about it. Occasionally, I saw an introduction of different advertisements implemented by wp in Baidu, so whether it can be implemented by zbp under Baidu, after testing, it really can (and the most sad thing is that the official group has a tutorial for adaptive display of different advertisements, but it is not easy to use ^ _ ^).

 The Z-blogPHP website is a tutorial for displaying different advertisements on the PC side and mobile end.jpg

Post a tutorial, please feel free if you like (PS: suggest Xiaobai find the developer of your theme and let him join, so as not to make mistakes in his own modification, which will lead to the inability to open the website)

First open the“ include.php ”File (Don't ask me what this file is, I don't know.) Add the following code:

 //Different advertisements are displayed on PC and mobile terminals function brieflee_is_mobile(){     global $zbp;     $is_mobile = false;     $Pad_List = '/touch|arm;| android|iphone|ipad|windows\sphone|kindle|gt\-p|gt\-n|rim\stablet|meego/i';     $UA = GetGuestAgent();     if(CheckRegExp($UA, $Pad_List) == true){         $is_mobile = true;     }     return $is_mobile; }

be careful: It is better to add it in the middle of the file. Of which“ brieflee "Modify it to the ID name of the topic, because zbp stipulates that the function name must start with the topic name.

Then add the following code in the area where you want to display different advertisements:

 {if brieflee_is_mobile()} Display mobile ads {else} Display PC advertisements {/if}

Then save. The background home page empties the cache and recompiles the template.

 Zbp Display Different Ads.png

The advertising background display of the theme of this site, please click the link as soon as you want: Brieflee theme - give you the best

    Comment List (Already three Of comments sixteen thousand two hundred and fifty-six Participation) Participate in the discussion
     Netizen nickname: Weizhuan Share
    2019-10-09 reply
    WeChat profit sharing network
    Benefits received every day
    Alipay consumption red packet, everyone pushes it every second
    http://www.tuibolao.com/post/17.html
    Another WeChat red packet, second push
    http://www.tuibolao.com/post/18.html
     Netizen nickname: Jieshan webmaster
    2017-08-04 reply
    There is no need to define zbp variable in is_mobile variable, and $zbp variable is not used
     Netizen nickname: none but Li
    None but Li Blogger
    2017-08-07 reply
    @Flash station master network Really, I don't know. Thank you. Have time to test.