There are lots of plugins available that will add a message box to the top of your posts if it’s above a certain age – e.g. 2 years old. However, I had a very specific requirement. After updating my site recently, I had to make changes to my posts to get them to fit with the new design. However, with over 1000 posts, it was going to be a long, long job to do them all. So I didn’t. I only did 2013 onwards. So, I wanted to display an appropriate message for any posts old than that – a set date rather than a moving time period.

I added the following to my functions.php to achieve this. Note that I use Bootstrap Shortcodes and used the CLASS for that to add a dismissible message box around the text.

So, to use, add the code to your own functions.php page, changing the date after which the message should appear (and, of course, change the output message and CLASS for your own unique requirements). Otherwise, feel free to use this code yourself, as you feel fit. I’m thinking, longer term, of converting this into a plugin.