Loading...

Tuesday, July 19, 2011

Display Adsense Ads Only on Older Posts in Wordpress

Did you ever wanted to display adsense ads only on older posts? Doing so will greatly improve your readership why because the people who read your blog regularly will not get distracted from the content due to the advertisements. And as most of the visits to your old blog posts will be from organic listings, their visit will result in high RPM. So in this scenario, both you and your reader will get benefited.

How to Display Adsense Advertisements only on Old Posts?

  1. Login to your wordpress dashboard
  2. Go to Appearance -> Editor
  3. Select Single.php file (found on the right side panel)
  4. Add the following code where you'd like to display your adsense ads.
    <?php
    if (strcmp( date("Y-m-d", strtotime("-5 day")), get_the_time("Y-m-d") ) > 0) {
    ?>
    #Replace this line with your adsense code#
    <?php
    }
    ?>

  5. In the above code, replace the #commented line with your adsense code (See High Paid Adsense Ad Formats). Also don't forget to replace the digit "5" with your desired number (number of old days).
That's it! From now on, Adsense ads will not appear on your new posts and will only visible to visitors who landed on posts older than 5 days (as per our above example)

0 comments:

Post a Comment

 

Receive all updates via Google+ and Facebook. Just Click the Like Button Below