JavaScript custom Location Insert Baidu affiliate ADS

Source: Internet
Author: User

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)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.