Display a custom message on old posts

Here’s a chunk of code for WordPress that will display a custom message on posts older than a certain date. You might ask, “Why would I need such a thing?” And I’d say you probably don’t but if the post is older than 60 days and not a monthly archive, the person has likely arrived via search engine or permalink.

So, who cares if someone is arriving via search engine? Well, they probably won’t stick around after you’ve given them their tidbit of information. However, you could direct them towards your site’s main page, some other content or even display some AdWords or other advertising (thus avoiding a hit to your loyal readers).

It’s a relatively straight-forward chunk of php code. You’ll probably want to put it in your post template, sandwiched between the function that displays content and the one that displays comments.

<?php 
	$entry_datetime = abs(strtotime($post->post_date)); 
	$time_since = time() - $entry_datetime;   
	$days_since = 60;
	if ($time_since > $days_since * 86400) :
?> 		
 <div class="message-age">
  ## Modify this message
  <p>This entry is more than 60 days old.</p>
 </div>
<?php endif; ?>

This code is GPLd, do whatever you want with it. You could have it display a different message for a post that’s a year old or two years old.

If there’s interest, I can turn this into a simple WordPress plugin but it doesn’t seem overly necessary.





Google Talk

Google Talk
The long-rumoured Google IM client arrives using the Jabber protocol and supporting voice calls. You need a Google id though, if you’re jonsing and still don’t have one I’ve got a few invites left.



Photos from Montreal

Waiting

Popped down to Montreal this weekend and stayed a night at Phil’s place. Didn’t get up to much, but I took a few photos Sunday afternoon. It’s still annoying not to have an lcd screen on my camera, I’ll get something new eventually. Here’s the full photo set on flickr.