If post hasn’t been modified recently in WordPress

Today an issue came up where a reader of one of a site I manage was referring to content that was out of date. Normally that’s not a problem but in this case it is a timely pandemic documentation page where the content is very likely to be out of date within a couple months if its not routinely updated.

To solve this challenge I decided to write a small function that will check the last modified date of a post and place an alert below the title and above the content. That notice would read…

This page has not been updated in 60 days. The information below may be outdated.

Which is a casual way of alerting the reader that if this information is timely perhaps check elsewhere on the site for a newer post. Likewise, if that person is looking for an older post they can safely disregard the notice. posting a discrete notice can come in handy depending on the context that brought a reader to the post.

Functions.php

<?php
// If post is older than 60 days return true
function jd_is_old_post($days = 60 ) {
	$days = (int) $days;
	$offset = $days*60*60*24;
	if ( get_post_modified_time() < date('U') - $offset )
		return true;
	
	return false;
}
?>

Place within the WordPress Loop

<?php
// If post is older than 60 days display this notice
if ( jd_is_old_post() ) {
	echo '<div class="old-post-notice">';
        echo '<p><strong>This page has not been updated in 60 days. The information below may be outdated.</p></strong>';
    echo '</div>';
} 
?>

Vacationing in Xubuntu 20.04

I finally decided to install 20.04 and test it out for a few days. I forgot how much I enjoyed the simplicity of the XFCE desktop environment. The classic quake inspired drop down terminal always makes me smile.

XFCE 4 drop down terminal terminal

If you’re interested in how to get the xfce4 terminal to work as a drop open keyboard shortcuts and add the following.

xfce4-terminal --drop-down

Then apply your favorite key combination, I like to use Ctrl + ` but you can pick whatever you like.

Tabs vs Spaces

I don’t know about the rest of you but when I download a code template from the web where the developer used spaces, I get triggered. Why would anyone use spaces over tabs?

https://youtu.be/SsoOG6ZeyUI
Silicon Valley Season 3 Episode 6: “Tabs vs Spaces” Scene

I often edit whole document to replace spaces with tabs just before I start using it. ????

Oh, for the record I use Vim over Emacs.