Hide Blog Post Date In Your WordPress Theme

by Steve on June 24, 2010

While visiting Lynn Terry’s Clicknewz blog, I noticed something that I hadn’t really given a lot of thought to: is there a reason to NOT display a blog post’s date? (Off-Topic Warning – Lynn writes a fantastic blog on Internet Marketing with posts like Taking Daily Action: Huge Goals, Little Steps – you really should check it out if you’re interested in making money on the net)

Anyway, Lynn doesn’t display post dates on her blog posts except for some of the archive listings. After checking out quite a few other blogs, I see that somewhere around 25% of bloggers do NOT put dates on their posts.

After communing with the great and powerful Google, I found this post by Darren Rowse of ProBlogger: Dates on Blog Posts – Should You Have Them? where he discusses the question at length.

I’m not going to get into the question of whether you should or shouldn’t display the date on your blog posts other than to say that personally, I find it annoying when I can’t find a post date. Knowing when a piece was written adds a certain relevance to my consideration of the post content.

One of the suggestions Darren made was to display the date only on recent posts:

Dates on Recent Posts But Not on Older Ones - I saw one blogger do this last year (I’m afraid I don’t remember who it was). They had hacked WordPress so that dates appeared on recent posts (within the last 3 months) but anything older than that did not have time stamps either on the post or comments. This meant that the blogger benefited from new posts looking new and took the potential distraction of old posts away from readers. I don’t know exactly how the blogger did it but presume they set up a rule that looked at the date of authorship and then determined whether the date would be displayed or not.

The ‘hack’ that Darren mentions is actually pretty easy, if you’re comfortable modifying your theme files. Using WordPress’s new “twentyten” theme that comes packed with WordPress 3.0, I’ll show you exactly what you have to do to show the post dates on single posts only if they’re fresher than 3 months old. 3 months is an arbitrary figure, by the way, so adjust it to whatever spins your prop.

Note: the new twentyten theme wraps up the post meta information ( date, author, etc.) into a function. When you disable this function, you’ll lose that line completely, exactly like Lynn’s posts.

I recommend that you do NOT use the built-in theme editor in WordPress, especially when you’re messing around with PHP coding. One misplaced semi-colon and you could render your blog DOA. Then the only cure is to use an FTP client and replace the screwed-up theme file. If you MUST use the built-in editor, be certain that you have a clean backup of the file you’re working on!

So, step one: locate the single.php file within the twentyten theme folder and make a backup.

Open single.php in your fav text editor. The section that holds the meta display code begins on line 25 and looks like this (disregard the line #s in the examples that follow):

<div class="entry-meta">
  <?php twentyten_posted_on(); ?>
</div><!-- .entry-meta -->

What we’re going to do is to insert a test – is the post less than 90 days old? If so, display the post particulars. If not, leave it blank.

To do that, we’ll use a simple ‘if’ statement, comparing the date 90 days ago with that of the post. We will use PHP’s useful strtotime() date conversion function to make things easy:

if ( strtotime( get_the_date() ) > strtotime( "90 days ago" ) ) {
<div class="entry-meta">
 <?php twentyten_posted_on(); ?>

The strtotime() function converts whatever is in the parentheses to a Unix timestamp. The function get_the_date() is a new WordPress 3.0 function that fetches the post date and returns it in the format specified in your preferences.

And there you have it – no more dates on posts older than 90 days old.

{ 9 comments… read them below or add one }

grow butt August 9, 2010 at 11:33 pm

How can I remove the entry_meta from Blog main page?


Jimmy September 9, 2010 at 3:30 pm

How about removing the date altogether? No 90 day (or any other) parameter?


Steve September 10, 2010 at 12:18 am

Sure – just remove all references to the_date(), or in the case of twenty-ten, twentyten_posted_on().


Jimmy September 10, 2010 at 3:23 pm

Thanks, Steve. Good site and blog you have here.

cocogodiva November 29, 2010 at 6:14 pm

What if I want to do the reverse, no date for recent post but show dates for older posts. How would I achieve this?

Thanks a bunch!


viagra December 30, 2010 at 3:20 am

Nice information,It’s understandable to me now, but in general, the usefulness and importance is overwhelming.To clear the debts through online we provide the best debt help options.you can visit our site to compare the options with our free debt test.


Junaidiey March 26, 2011 at 1:38 am

hey there… thanks for this entry.

btw, can you share about how to hide the blog author name and entry tag?


Compra Subito Kamagra April 18, 2011 at 3:43 am

You have a very good blog that the main thing a lot of interesting and useful!


acheter kamagra May 26, 2011 at 2:14 pm

Informations de Nice, il est compréhensible pour moi maintenant, mais en général, l’utilité et l’importance est énorme.


Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>