Hi,
So I migrated to WordPress from Joomla (long time Joomla user), but I am having an issue with a custom code not working, or should I say, "semi-working" with WordPress.
It is basically a custom code to display google adsense. It worked on my Joomla website, but since I migrated to WordPress and copy/pasted the code to the WordPress website, I only have "sponsored links" showing, but none of the actual adsense links. Looking back at my Joomla website this still works... seems I hit a wall here. Can anyone help?
[ Moderator note: please wrap code in backticks or use the code button. Do not use blockquote. ]
<!-- google_ad_section_end -->
<script type="text/javascript" language="Javascript">
<!--
// script to get and display adwords.
function google_ad_request_done(google_ads)
{
var s = '';
var i;
if (google_ads.length ==0)
{
return;
}
// check for the different content types that can be returned and deal with them appropriately.
// as far as I know we only actually do text.
// if an image is returned...
if (google_ads[0].type == "image")
{
s += '<a href="' + google_ads[0].url +
'" target="_top" title="go to ' + google_ads[0].visible_url +
'"><img border="0" src="' + google_ads[0].image_url +
'"width="' + google_ads[0].image_width +
'"height="' + google_ads[0].image_height + '">';
}
// if flash is returned...
else if (google_ads[0].type == "flash")
{
s += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
' WIDTH="' + google_ad.image_width +
'" HEIGHT="' + google_ad.image_height + '">' +
'<PARAM NAME="movie" VALUE="' + google_ad.image_url + '">' +
'<PARAM NAME="quality" VALUE="high">' +
'<PARAM NAME="AllowScriptAccess" VALUE="never">' +
'<EMBED src="' + google_ad.image_url +
'" WIDTH="' + google_ad.image_width +
'" HEIGHT="' + google_ad.image_height +
'" TYPE="application/x-shockwave-flash"' +
' AllowScriptAccess="never" ' +
' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
}
// we have HTML returned, display this verbatim
else if (google_ads[0].type == "html")
{
s += google_ads[0].snippet;
}
// text, we need to format this up...
if (google_ads[0].type == "text")
{
s += '<ul style="list-style:none;padding-left:5px;margin:5px 0;">';
for (i = 0; i < google_ads.length; ++i)
{
s += '<li style="padding: 5px;background-image:none;">' +
'<a href="' + google_ads[i].url + '">' +
'<b>' + google_ads[i].line1 + '</b>
' +
'</a>' +
'<span style="color:#000;font-size:11px;">' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</span>
' +
'<a href="' + google_ads[i].url + '">' +
google_ads[i].visible_url +
'</a>' +
'';
}
s += '';
} // end type text
document.write(s);
return;
}
// set up all the constants
google_ad_client = 'client id'; // substitute your client_id
google_ad_channel = 'my channel';
google_ad_output = 'js';
google_max_num_ads = '3';
google_ad_type = 'text'; // type of ads to display
google_language = 'en';
google_encoding = 'utf8';
google_safe = 'high';
google_adtest = 'off';
google_ad_section = 'default';
//-->
</script>
<div style="margin-top:5px;">
<fieldset style="width:580px;border:1px solid #CCC;margin:10px 0px 10px 10px;padding:0px 0px 0px 5px;background-color:White;clear:both;">
<legend style="font-weight:bold;color:#000;">Sponsored Links</legend>
<script type="text/javascript" language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</fieldset>
</div>
PS; I changed the Google Ad Client number and Ad Channel name in the code above.