fbpx

Hack your way to better Adsense ad placement

This is a quick tip I’d like to share to those running WordPress with themes that do no have a “single.php” page. The problem with those themes is that whatever ad you paste in the index.php will both appear on the main page and the full entry page. Thus, if you want to use the high performing ad sizes (336×280), it’ll ruin your blog’s layout. Others resort to just using the standard 486×60 or use the comments template instead (which doesn’t completely solve the problem).

If you want your ads to show up just in the full entry page and not in the main page, you will need to do some simple hacking which involves a little PHP:

Yugatech 728x90 Reno7 Series
<?php
if($single)
echo(”
<script type=\”text/javascript\”><!–
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = \”336x280_as\”;
google_ad_type = \”text_image\”;
google_color_border = \”FFFFFF\”;
google_color_bg = \”FFFFFF\”;
google_color_link = \”333333\”;
google_color_url = \”999999\”;
google_color_text = \”333333\”;
//–></script>
<script type=\”text/javascript\”
src=\”http://pagead2.googlesyndication.com/pagead/show_ads.js\”>
</script>
“);

?>

The PHP function if($single) is just a condition that tells the page to show the ads (echo function) only when it is on the full entry page.

Take note of the backslash (\) added just before each double quotes (“) in your original Adsense codes.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 976 other subscribers
Avatar for Abe Olandres

Abe is the founder and Editor-in-Chief of YugaTech with over 20 years of experience in the technology industry. He is one of the pioneers of blogging in the country and considered by many as the Father of Tech Blogging in the Philippines. He is also a technology consultant, a tech columnist with several national publications, resource speaker and mentor/advisor to several start-up companies.

5 Responses

  1. Avatar for t2ZK5NKWey t2ZK5NKWey says:

    Hi! Very nice site! Thanks you very much! p1wTH6Z1GFsZh

  2. Avatar for mediamaster mediamaster says:

    take a look at my blog on adsense. It covers how google javascript works and how you can maximize your ad revenue by behavorial targeting ads. It is a series of tutorial like articals. you comments are welcome.

  3. Avatar for markku markku says:

    I think the more recent archives earn more than new entries, specifically those around a month old.

  4. Avatar for Abe Olandres Abe Olandres says:

    I am actually doing a month-long experiment to see if the archives are earning mroe than the current entries. A quick PHP snippet would do the trick, I suppose.

  5. Avatar for markku markku says:

    This works best in varying the appearance of your entry pages. I think we should compile more adsense tricks. ;)

Leave a Reply
JOIN OUR TELEGRAM DISCUSSION

Your email address will not be published. Required fields are marked *