Lunarpages Internet Solutions Blog
  • Home
  • About Us
  • LunarForums
  • Free Web Tools
  • Free WP Themes
1

Better AdSense Optimization with WordPress

23 September, 2009 - Customer Service, Mitch Keeler, Wicked Sites

Looking through Google AdSense advice and suggested places to put your advertisements, I often see it suggested to put the ads between your posts on the index page.  Having searched around for ways to get it done, I found none that were easy – until I found this page.

This is the guide I followed from tamba2.org.uk’s page on this issue.  I hope this comes in as handy for you as it did for me, because it took me forever to find a code combination that worked exactly like I wanted it to.

Copying from above, you would use this instead:

<?php
$postnum = 1;
$showadsense1 = 1;
$showadsense2 = 2;
?>

which would go at the top.
Again copying from the above, you already have this:

<?php if ($postnum == $showadsense1) {
echo ‘
Your adsense code goes here
‘;
} ?>
<?php $postnum++; ?>

and you would add another block below the first ad, but above the counter at the bottom. Here it is all together:

<?php if ($postnum == $showadsense1) {
echo ‘
Your adsense code goes here
‘;
} ?>
<?php if ($postnum == $showadsense2) {
echo ‘
Your adsense code goes here
‘;
} ?>
<?php $postnum++; ?>

The first bit says the values, then the values are checked each time WP goes through The Loop. If the counter matches what your value is, the ad is shown. Changing the numbers lets you change the placement.

Hope that helps, and many thanks to the tamba2.org.uk site.  Be sure to check out this page for more help on AdSense optimization within WordPress.

  • http://socalvegblog.com Aaron

    For those of us who would rather use a plugin than edit files… the plugin “Advertising Mgr” works well for me. You can find it here: http://code.openx.org/projects/show/advertising-manager
    (no, I’m not part of the project)

Archives

Categories

View more:

  • About the Lunarpages blog
  • Best Blog Hosting Guide
  • BOTW.org 40% Discount
  • Contact Lunarpages
  • Free Online Tools
  • Free Webmaster Downloads
  • Free Wordpress Themes

Best Web Hosting

Lunarpages.com Web Hosting

Recent Posts

  • Customer Showcase – SportVision
  • 5 Mobile App Trends for 2012
  • 10 Technology Trends for 2012
  • 5 Open Source CMS for Websites
  • Google Will Change Your Web Marketing in 2012

Recent Comments

  • Roger on 5 Mobile App Trends for 2012
  • Web Hosting Reviews on 2012 Resolutions Promotion
  • Graham Gillen on Plesk 9.5.2 Backup Tutorial
  • Hosting forums on Free Layouts from Open Web Design
  • Best forum hosting on 5 Reasons Why VPS Hosting May Be the Solution You’ve Been Searching For

@Lunarpages Feed

Who We Are

  • Web Hosting Services
  • About us
  • Partners
  • Affiliate Program
  • Specials
  • 24/7/365 Support Desk
  • Community Forum
  • WIKI

Our Products

  • Colocation Services
  • Fully Managed Services
  • Dedicated Hosting
  • VPS Hosting
  • Microsoft Exchange
  • Open-Xchange
  • Fax To Email
  • Linux Hosting
  • Windows Hosting
  • Reseller Hosting
  • Quicksite Website Builder
  • SEO & SEM Services
  • Payment Processing
  • SecureLive Website Security
  • Tremendesk - Help Desk Solution

Connect With Us

Stay in touch with us!

Sign up for our monthly newsletter to receive updates, news, and current promotions!

Twitter
Facebook Google+ RSS Feed


© 2000 - 2011 Add2Net, Inc. "Lunarpages", "Add2Net" and the "Lunar Symbol" are the trademarks or the Registered trademarks of Add2Net, Inc.
All rights reserved. Unauthorized use is prohibited.