Thoughts, information and reflections about technology

Sort WordPress posts by the last updated date.

I had two location sites where I wanted to have updated posts show in the list of posts based on their last updated date. I was able to accomplish that with a free plugin and a quick configuration of the plugin

Do you create new posts or update old posts?

I have two location/destination based sites where I have restaurant and entertainment reviews. For example, suppose I visited a restaurant in 2018 but want to update it with current information about outdoor seating and Covid-19. There are two ways to do this. Create a new post and cross link them or update the existing post.

Creating a new post:

One advantage of creating a new post is that in a default WordPress installation, it will be at the top of the posts lists when published. (Assuming your home page is a list of posts which my pages are)

However, there are several points to consider:

Re-creating content.

If you create a second post, or even a third, you will have to do some unnecessary work creating the new post, adding images and tweaking your SEO settings (IE Yoast). In most cases, you would want to crosslink between the posts which could be tedious.

If you update a current post, you can probably do that more quickly since your categories, tags, featured image and SEO settings remain the same.

SEO considerations

For the most part, one strong page should do better in the long run than two or more pages on the same basic subject.

User experience

For the types of sites I’m doing, the user experience is probably better when existing pages are updated instead of creating additional pages.

The last updated attribute for a post

The database for a WordPress site includes the date of the last update. However, it doesn’t show by default. There are two ways to show and use the last updated date: Adding code to your template or using a plugin

Adding code to the template to show the last update date.

There are a number of examples online of how to modify your template code to show the date of last update. I’ve done similar modifications before. I decided to avoid this if possible. 

Using a plugin

There are a couple of plugins that were designed to accomplish this task. I found one, WP Last Modified Info, that was compatible with my version of WordPress (5.4.2). 

Always back up your WordPress site before adding any plugins or modifying code.

Plugin installation and configuration

The plugin is free but the author does take donations.  It installed easily. Once it was installed and activated, it needed some minimal configuration. 

Post options

The post options configuration was simple. Turn the plugin on for posts, show on archives and set the gap. 

I set the gap to one day. If I modified a post several times while creating it, it will not show a last updated on date. However, if I modify it a couple of days later, the last udpated on date will show

WP Last Modified Info plugin posts configuration

Misc Options

This is the key to making the plugin work as I intended. When you set the “Default Frontend Post Sorting Order” to “Modified Post First” your modified posts will show in the list of posts based on their last updated date, not their created on date. 

Front end results

After adding and configuring the plugin, posts were now showing ordered by the last updated on date.

For example, I had a post about the Surflight Theater that was originally created in February of 2018. That would place it well down in the list. Since it has fresh, updated content, I want it at the top of the list. That is exactly what I am getting.

Similar Posts:

No tags for this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact me
Archives
Categories
Recent Comments