• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Startup Hero

The Official Blog Of Name Hero

Learn To Fly Above The Competition Get Started
  • HomeWelcome
  • CoursesVideo Training Center
  • About UsWhat is StartupHero?
  • BlogGet the latest
  • Start HereStartup 101
  • SpeakingPodcast & Media
  • ResourcesTools to help You
    • Reselling WordPress Hosting
    • Resell Hero
    • How To Start A Blog
  • NameHeroCloud Web Hosting

How To Sort Posts By The “Last Modified” Date

By Bhagwad Park on January 11, 2023 0

How To Sort Posts By The “Last Modified” Date

I’m updating a bunch of older posts on my site, and I’m trying to see which posts have gone the longest without modifications. Unfortunately, WordPress’s list of posts and pages can only be sorted by “Date”, which means the date of publication. There’s no in-built way to create a new column called “Modified Date” and sort by that.

So here are two ways to sort WordPress posts and pages by the “modified date” instead of the publication date. The first one is easy and doesn’t require any coding. The second method includes code to paste into your theme’s functions.php.

Method 1: The Easy Way – No Coding Required

If you’re not looking for a permanent solution and want the WordPress admin dashboard to sort your posts or pages by the modified date once in a while, then there’s no need to use a plugin or fiddle around with code. You need to change the URL that appears when you sort by “Date”.

Navigate to the list of posts or pages, and click the “Date” column, so that it sorts the posts by the date of publication. Now modify the URL and replace “date” with “modified” and change the order to “asc” instead of “desc” like this:

https://www.example.com/blog/wp-admin/edit.php?orderby=modified&order=asc

Modify the URL to Sort by Modified Date in Ascending Order
Modify the URL to Sort by Modified Date in Ascending Order

Naturally, you want to replace “example.com/blog” with the name of your WordPress website. Loading the above URL will sort the entries on the current page by the modified date. Setting the “order” parameter to “asc” will give you the oldest posts to have been modified, and “desc” will show you the most recently modified posts first.

Neat huh?

Method 2: Adding Code to Sort by the Modified Date

If you’re looking for a more permanent solution, add the following code to your theme’s functions.php file:

function sort_by_modified( $wp_query ) {
	global $pagenow;
	if ( is_admin() && 'edit.php' == $pagenow) {
		$wp_query->set( 'orderby', 'modified' );
		$wp_query->set( 'order', 'ASC' );
	}
}
add_filter('pre_get_posts', 'sort_by_modified' );

If you don’t know how to add code to WordPress like this, read my tutorial on how to add code to WordPress without a plugin.

The above code changes the query on the backend of the WordPress admin that lists the posts or pages and shows a new one instead. True, the interface becomes a bit misleading because you get the impression that it’s sorting posts by the date instead of the modified date, but who cares? I’m not going to figure out how to change the name of the date column for cosmetic reasons!

Sorting by the Modified Date is Critical for SEO Maintenance

I’ve just realized that I have several posts on my site WP-Tweaks.com that are several years old. Most of these are tutorials, so their information is still relevant, but some things can be refreshed. The screenshots with better resolution reflect the changes in the WordPress editor with Gutenberg, new image WEBP formats, product descriptions, and titles.

For this kind of SEO task, sorting the posts in order of the last modified date is a godsend. I prefer to use the URL method of sorting the posts since I only need to do it once in a while, and I think that will be true for most people. After all, why change something permanently when the requirement is so niche?

You need to use the coding solution only if you have a compelling reason to always sort the posts by the modified date. I hope you found this tutorial helpful!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Connect With Us!

Superhero Resources

Fix Common Issues

  • How To Setup Free And Automatic SSL Certificates
  • How To Setup Cloudflare With Railgun
  • How To Fix Memory Exhausted Errors In WordPress
  • How To Edit PHP Version/Upload Limit/Add Extensions
  • How To Move/Migrate Your Business To Name Hero

Free Guides

  • How To Setup NameHero Hosting
  • How To Create A Web Hosting Business With WordPress
  • How To Start A WordPress Blog
  • How To Migrate WordPress To A VPS
  • How To Speed Test And Optimize Your WordPress Website
  • Magento 2.X Installation Guide
  • How To Clean Up A WordPress Hack

Training

Recent Posts

  • The Best WordPress Plugin To Combat Plagiarism
  • Is It Time to Bring Back Blog Comments?
  • Two Filters That No Longer Work In Gutenberg (And Workarounds)
  • Migrating To The New Cloudflare Managed Rules Interface
  • How To Sort Posts By The “Last Modified” Date
  • How To Make WordPress Send E-mail From Another Address
Subscribe in a reader
  • Web Hosting
  • WordPress Hosting
  • Reseller Hosting
  • VPS Hosting
  • Twitter
  • Facebook
  • LinkedIn
  • YouTube
  • FTC Disclosure
  • Earnings Disclosure
  • Privacy Policy

Copyright © 2023 · Smart Passive Income Pro on Genesis Framework · WordPress · Log in