WordPress How to insert a custom position in the article Baidu affiliate ADS? For example, set a tag bit, insert the mark bit, this position will display ads. WordPress can use the Add_shortcode function to set a short label, the implementation of the article page custom position inserted Baidu Alliance ads.
Directly on the code:
Php
The code is as follows |
Copy Code |
//Baidu ad Shortcode function Bdad ($attrs) { if = = $attrs [' Size ']} { $bdad = << <bdad <div style= "float:right;" <script type= "Text/javascript" /*300*250 was created in 2014-08-23*/ var cpro_id = "u1674017"; </script> <script src= "http://cpro.baidustatic.com/cpro/ui/c.js" type= "Text/javascript" ></ Script> </div> Bdad }else{ $bdad = <<<bdad <div style= width:580px;margin:0 auto; " <script type= "Text/javascript" /*580*90 was created in 2014-08-13*/ var cpro_id = "u1657518"; </script> <script src= "http://cpro.baidustatic.com/cpro/ui/c.js" type= "Text/javascript" ></ Script> </div> Bdad if (Is_single ()) { return $bdad; } return "; } Add_shortcode (' Bdad ', ' Bdad '); |
Note The last code: Add_shortcode, the first argument is the tag bit name, and the second is the function name that is executed. After adding the above code in the subject functions.php, enter {Bdad} or {Bdad size= "300″}" at any custom position in the article (note that this {} is represented by [], which is replaced with this tag).
From the above set reminds me of the recent improvement of a paragraph JS load Baidu Advertising code example
The code is as follows |
Copy Code |
Function DW (a) { Document.writeln (a) } Function Bdjs (d, b) { var c = ' <script src= ' http://cpro.baidustatic.com/cpro/ui/c.js ' type= ' text/javascript ' ></script> '; var a = ' <script src= ' http://cpro.baidustatic.com/cpro/ui/f.js ' type= ' Text/javascript ' > </script> '; if (b = = "C") { dw (' <script type= "text/ JavaScript ">var cpro_id =" + D + ' ";</script> ' + C" } else { ; DW (' <script type= "Text/javascript" >var cpro_id = "' + D + '";</script> ' + a) &nb sp; } } function dy (b) { if (b = = "BCR") { Bdjs ("u91397", "C") } if (b = = "baidu580") { Bdjs ("u776243", "C") } if (b = = "Bdtxt") { Bdjs ("u1589648", "C") } } |
Directly when HTML calls ads
The code is as follows |
Copy Code |
<script>dy (' BCR ') </script> This is the specified location to call the specified code, very simple. DY (b) |