Google Adsense code (javascript) in wordpress pages / posts
Tags: Blog, Google, PHP, WordPress
For ages I could not work out why google ad’s included within a wordpress page didn’t work (in fact this applies to a post too). When google support pointed out that there was <br/> ’s in my code the penny finally dropped.
So here’s the deal, I pasted the following code into my page: (In the wordpress dashboard)
<!– FireFox Referral –>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;google_ad_height = 60;
google_ad_format = “180×60_as_rimg”;
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>
adsense ad
<!– Adsense Referral–>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = “180×60_as_rimg”;
google_cpa_choice = “CAAQ__qy0gEaCP_s0gMhUOtXKL3D93M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>
and look what happens…..
firefox ad
adsense ad
Wordpress adds page formatting to the java script that is posted, so if you look at the source, what you actually get is…
<script type=”text/javascript”><br />
<!– <br />
google_ad_client = “pub-6732086233580907″;<br />
google_ad_width = 180;google_ad_height = 60;<br />
google_ad_format = “180×60_as_rimg”;<br />
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”; <br />
//–><br />
</script><br />
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script><br />
… DOH !!!!!!
