The impact of removing dates from old WordPress posts depends on your content: a news-oriented site would probably be best served by keeping dates intact; a how-to site, not so much–readership may even be hurt by date display.
How? If you have lots folks finding your site via older, single posts in search results, the date may make the content appear outdated when it might be just as helpful as when originally written–and some searchers may be mistakenly assuming your older gems aren’t just as valuable as your newer ones. Oh no!
Sometimes you may want to include specific content based on the date as well–advertising for older posts, perhaps, or social bookmarking icons for newer posts. So how do we do this? Like most stuff in WordPress, there is more than one way to skin that date-display cat.
WordPress Date Control Plugins?
You want to do something special in WordPress, the starting point is the WordPress plugin directory to see if that wheel has already been invented! I was surprised there weren’t more date-based control plugins available.
The only thing I found written explicitly for this function was the Date-Exclusion SEO plugin. Now, this plugin has not been updated for WordPress versions since 2.71. Using outdated WordPress plugins is not always a problem, however. I tested this with a current WP installation (2.82) and it worked for me…mostly.
I happen to use the Thesis theme, which has the word “on” hard-coded to appear between the author’s name and date, so using this plugin only displayed “Author name on” and a blank space. For most themes, you’d go into the index template (index.php), and remove the word “on” to fix this. To accomplish this task with Thesis, you’ve gotta do a little dancing–such as removing the generated byline and replace it with your own conditional code (via that magic functions.php). See special considerations for theme frameworks .
The CMS Control Plugin initially sounds like it may do the job, but it’s actually a plugin to simply the admin interface. [1]
So there is one down-and-dirty option to hide the date you may be able to use without having to get your hands dirty in the code. But if you need more flexibility or are trying to limit your raging WordPress plugin addiction, you still have options.
PHP Code for WordPress Date Suppression
Plugins aside, you can always control date display via PHP code. If you are editing your theme files directly, make yourself some notes on what theme edits you’ve made on what templates, the date and the reason for the edit. (If you keep notes in a single place, this will help tremendously when you need to upgrade or change WordPress themes. You don’t want to be relying on your memory or you’ll be cussing yourself profusely–at least I sure do!)
Date display in WordPress is done with PHP code that looks like this <?php the_time(‘F jS, Y’) ?>; to suppress dates on older posts, you’ll usually be looking at the main page template, index.php. However, exact placement and code will depend on your theme. Extra credit: format the date the way your way–see what the various letters mean in the PHP date documentation. Apologies if PHP code makes your eyes water.
There are many different approaches, but they all amount to the same thing: calculate the post age, and decide what to display based on that calculation. The code below will show a date for posts less than a month old, but suppress the date for posts a month or more old. In a standard WordPress theme, find the date line in single.php.
In the default WordPress theme, the line displaying the date looks like this:
<small>[<?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
Take that portion of the code <?php the_time(‘F jS, Y’) ?> and replace it with this: [2]
<?php
$today = date('r');
$articledate = get_the_time('r');
$difference = round((strtotime($today) - strtotime($articledate))/(24*60*60),0);
if ($difference >= 30)
{
?>
<!-- Aged Gem -->
<?php
} else {?>
<!-- Fresh Gem --><strong><?php the_time('F jS, Y') ?></strong>
<?php
}?>
Notes For Those Using Theme Frameworks
For those with themes utilizing functions.php for customization, the code is essentially the same, except you’ll be wrapping it up as a PHP function. Since you don’t edit the templates directly in theme frameworks, you’ll be adding your modified date display using one of the theme’s hooks after suppressing the default date display. Consult your theme’s documentation/support for specifics of doing this for your theme. A few resources to help you get started:
- Michael Gray’s Date-Based Triggers Tutorial (Thesis Theme)
- Rae Hoffman’s Hooks for Dummies Tutorial (Thesis Theme)
- Marko Saric’s Thoughts on Writing Timeless Blog Posts & Bylines (Thesis Theme)
- Ian Stewart’s How I used a WordPress Child Theme To Redesign My Blog (Thematic Theme)
Hope you find this helpful, and I’ll be glad to answer any questions in the comments if I can. Please note, however: I am not a programmer and do not play one on the internet.
photo credits: Laughing Squid & dier madrid
Footnotes- Thanks to the CMS Control author for this clarification in the comments. [↑]
- Big thanks to David Yeiser, for providing the code snippet I
blantantly liftedgratefully adapted for this purpose. [↑]





{ 2 comments… read them below or add one }
Hi – good topic for your post and something a-lot of people don’t think about. I like your suggestion there – just what I would have done, but thanks for sharing.
I am the author of the WP-CMS Post Control plugin you mention. It is designed to modify the admin panels of the WordPress ‘write post’ and ‘write page’ panels of WordPress. It allows the removal of options and panels to simplify the interface, along with other post related controls. It isn’t designed to hide/modify the post date on your public facing website (thanks for the mention – but sorry for the mixup!), but it will hide this option when creating or editing a post/page for a logged in user/admin.
Thank you so much for the clarification! That’s what I get for writing about a plugin that I haven’t used. Will correct the post to reflect accurate information.
And thanks for being a plugin-author. I appreciate all the work you guys do!
{ 2 trackbacks }