Flag WordPress Posts as Outdated

Posted by admin on December 13, 2009 under Tech Tips | Be the First to Comment

The following outlines the process of dynamically adding a blockquote message at the top of any post you have flagged as being “outdated”.  Over time, your posts can become outdated or even completely inaccurate, especially if you’re running a tech blog, since software constantly changes. This will help warn readers that there may be issues with the post in it’s current condition.

I did some digging around and couldn’t find an official plugin that took care of this.  I did however stumble across a blog post by Trey Piepmeier that helped me understand a fairly straight forward method of doing it yourself.  I typically don’t like to rehash work someone has already discussed, but I figured it would help to give a little more detail for those interested.  Depending on your PHP and WordPress theme modification skills, you can change this however you like.

PLEASE MAKE A BACKUP OF YOUR THEME BEFORE CHANGING ANYTHING.

You can place the following PHP “if” condition just BELOW the code referencing your post title and ABOVE the code referencing your post content. The get_post_meta() function assigns the $status variable with the value of a custom field you will later define as “outdated”. If it matches, then a blockquote message will be printed, otherwise it will be skipped and the post will continue as normal.

WARNING! THIS POST HAS BEEN MARKED AS OUTDATED!

Enter some useful message here about the article being old.

Depending on your theme, this can typically be done in your themes index.php and single.phpfiles, but you should also update any other you use to publish posts from.

Then, all you need to do is edit any of your outdated posts and add a custom field with the name of “status” and a value of “outdated” without any quotes and your work is complete.
outdated custom field

An example of what this might look like on your blog is shown below.

outdated post example

Please feel free to leave comments, suggestions or concerns. A great deal of help on figuring this out was also provided in the #Wordpress IRC channel on irc.freenode.net. If you find yourself in a pickle, there’s always someone there willing to help you out.