A tutorial on displaying different advertisements on PC and mobile sides of Z-blogPHP website

 Blogger: Li None but Li 2017-08-03 sixteen thousand and forty-one 3 comments

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

The End

Published on: 2017-08-03, unless otherwise noted Li Yang's personal blog template demonstration station Original article, please indicate the source for reprinting.