Dukeo » WordPress » Old Posts Ads: How To Display Ads on Old Posts Only

Old Posts Ads: How To Display Ads on Old Posts Only

Steven 13 responses WordPress

You may not be aware of this fact yet, but your regular visitors are less likely to click on your ads than one-time visitors. Since the presence of advertising on your blog could annoy your loyal readers, it might be a good idea to display ads only on old posts.

In order to display ads only on old posts with WordPress, first, you need to create a function that will determine if a post is to be considered old or not. To do that, simply paste the following code in the functions.php file of your WordPress theme folder:

function is_old_post($post_id=null){
  $days = 15; // Number of days for a post to be considered OLD
  global $wp_query;
  if(is_single()) {
    if(!$post_id) {
      $post_id = $wp_query->post->ID;
    $current_date = time();
    $offset = $days *60*60*24;
    $post_id = get_post($post_id);
    $post_date = mysql2date('U',$post_id->post_date);
    $cunning_math = $post_date + $offset;
    $test = $current_date - $cunning_math;
    if($test > 0){
      $return = true;
      $return = false;
    $return = false;
  return $return;

The second step is to call this function in the single.php file in your WordPress theme folder. Simply paste the following code in the loop, where you want your ads to be displayed:

<?php if(is_old_post()){ ?>
<?php } ?>

If you enjoyed this article,
Get email updates

Join for Free »


  1. Dana

    Wow! I am very surprised, all of this is new information to me! Although, if I think about it, it does make sense that loyal readers would just tune out any advertisements, or even ignore them. Very interesting, thanks!

  2. Michelle

    This is news to me! I didn’t know 1) that new readers were more likely to click on advertisements, and 2) that it was possible to only have adverts on your old posts. And this is why I read blogs to keep up with technology. :)

  3. Shad

    So thankful to have someone else writing these codes and posting them like this. Very cool, thanks!

    1. Liz

      Me too! :P

  4. Gorman

    Like Dana, this concept had never really occurred to me before. However, I think if any of your readers are ignoring your ads, it could be that the ads are not tailored to them enough, and you need to do some extra research, or chose your ads more carefully.

    1. Mitch

      That’s a solid point, Gorman. The whole point of advertisement is to try to reach a market that will be interested. If the ads you’re running are not getting much success, maybe it means you should change the ads.

    2. Mike

      This is a good dialogue, gentlemen. Good thoughts going around. :)

    3. Gorman

      Well, just like this site, all of my blogs serve as live case-studies. So it would interest me to try shifting some of the variables and seeing what occurs. I could try this technique that is posted above for a 2 week period of time, and see if that changes anything. And I could try changing adds and measuring the changes and then do both and see what works best.

  5. Anon

    I don’t want to bust anyone’s bubble, but is there any solid proof or research done about this? How do we know that new readers are more likely to click on ads, or that ads actually end up annoying loyal readers? I can see how that would make sense, but is there any hard data?

    1. Sarah

      You are a bit of a bubble buster, aren’t you? :) It’s ok, I think it makes sense to challenge new information, but think about it, it does make sense right? Plus its anyone’ choice whether they use the code or not. To each his own!

    2. John

      I’m kind of with Anon on this one, I’d like the see proof that this is in fact what happens before I go changing up my site. But I guess one thing we could do it just try it and measure the success level, and take it off if it doesn’t seem to work. Do a little home-experiment.

  6. Amanda@buysellwordpress

    Excellent news! I think that this can be an excellent opportunity and everyone will enjoy using it

  7. Mike

    Does this only work for WordPress?