How To: Hide Dates of Outdated Posts in WordPress for SEO

Using this guide easily hide dates of outdated posts in wordpress. Let’s consider from an SEO point of view as to how hiding timestamp for old posts will get you more CTR.

You might already know that Google shows the timestamp of your post in search results. Now let’s check out how these timestamps  can be a boon to you in some cases, and can act as a curse too.

Pros and Cons of displaying the date for a post

Say, you had written a post titled ‘best mobile phones’ back in 2007. Now, if a Googler searches with the same keywords, he is most likely to click on a post written in 2012 rather than 2007! Why? Its simple, because your post has become outdated.

Aren’t you missing out on the clicks by unnecessarily displaying the dates in the snippets? Of course, you are! Now how to avoid this trouble? This can be achieved by hiding the dates for posts which are older than a month.

How to achieve maximum Click through rate?

By doing this,

  1. People will go ahead and click on your outdated (a month old) post, because they never know when the post was published as you are hiding the date
  2. People are much likely to click on your most recent (less than a month old) post, because your content is considered up-to-date as you are displaying the date in the google snippet

Now lets check out how to make this possible.

Code to hide dates of outdated posts in wordpress

Step 1: From your WordPress dashboard, go to Appearance > Editor. Click on single.php and look for this time function:

<?php the_time('F j, Y'); ?>

Depending on your theme, it may also be the date function.

Step 2: Replace the time function, with this code:

$today = date('r');
$articledate = get_the_time('r');
$difference = round((strtotime($today) - strtotime($articledate))/(24*60*60),0);
if ($difference >= 30)
<!-- Old Post -->
} else {?>
<!-- New Post --><?php the_time('F jS, Y') ?>

Finally click on Save changes. If you want to change the time duration, then modify 30 to some other value.

Wasn’t that easy? Final step is to test if everything is working fine. If the date is no longer showing up on your old posts, then the function is working as it should.

Thanks for the code Dixie!

Subscribe to our Weekly Newsletter

I take your privacy very seriously


  1. shafeeq@how to make money from online Reply

    can i this trick blogspot? i mean can i hide dates from url?

Leave a Reply

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

Notify me of followup comments via e-mail.