How to Sort Posts by Modification Date in WordPress (Backend)

Last updated on Apr 8, 2025

In WordPress, you can manage your posts from the Posts screen by going to Posts -> All Posts on the dashboard. By default, WordPress displays the posts in chronological order.

Meaning that the newest post is placed at the top, followed by the posts by the publication date.

With the chronological order, the posts you published earlier will be placed rearward, even if you have edited them.

For a certain reason, you might want WordPress to sort your posts by modification date instead of publication date (chronological order). This post will show you how.

Shortcuts ⤵️

When Do You Need to Sort Posts by Modification Date?

WordPress is a content management system (CMS) by nature. Part of your job of managing content is to update it.

You need to update your posts on a regular basis to keep them relevant to your readers. In fact, editing the existing posts should be a priority in your editorial workflow.

And if you often update your posts, at a certain point, you want the posts you last edited to be placed at the top spot. Especially if you already have over 100 posts.

By sorting your posts based on modification date, it becomes easier for you to decide which posts need to be edited first.

Ideally, you edit the posts you last edited.

Sorting Posts by Modification Date in WordPress (Backend)

WordPress has no built-in option to sort posts by modification date in the Posts screen. Thankfully, WordPress is an open source platform so that you can add a custom feature via custom code.

If you have a coding background, no worries. I will also show you the no-code approach of how to sort posts by modification date in WordPress.

No-Code Approach to Sort Posts by Modification Date in WordPress

You can use this method if you have no coding background. But keep in mind that this method is a temporary solution. You need to redo the steps every time you login to your dashboard.

To sort posts by modification date using this method, first, login to your WordPress dashboard and go to the Posts screen (Posts -> All Posts).

Once you are on the Posts screen, modify the URL by adding the following string right after edit.php.

The string: ?orderby=modified&order=desc

The final URL after you add the above string should look like this:

https://yourdomain.com/wp-admin/edit.php?orderby=modified&order=desc

Edited URL

After you hit the enter key on your keyboard, you should now see your posts are sorted by modification date.

The above URL will place the last modified post at the top order.

If you want to place the post you earliest edited at the top order, you can replace the parameter from desc (descending) to asc (ascending).

Your final URL should be like this:

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

Custom Code Approach to Sort Posts by Modification Date in WordPress

If you want a permanent solution to sort posts by modification date, then you can use the following code snippet.

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

The above code snippet will automatically sort your posts by modification date every time you go to the Posts screen without needing to edit the URL.

The code applies to all users regardless of their role.

Adding the Code

The easiest way to add the above code snippet is editing the functions.php file of your WordPress theme. This is the most common method to add a custom function in WordPress.

Alternatively, you can also use a custom code plugin like CodeSnippets or create a custom plugin dedicated to accommodating custom functions.

I have published a detailed guide on how to add custom functions in WordPress which you can read if you have never added a custom code before.

In this particular example, I will show you how to add the code by editing the functions.php file.

Before you start, make sure that your security plugin (if you have one) doesn’t disable the theme file editing capability in WordPress.

Security Optimizer from SiteGround is one of the security plugins that disable theme file editing capability in WordPress.

Once you are ready, login to your WordPress dashboard and go to Appearance -> Theme File Editor.

🚨 If you are a block theme user, you can find The File Editor under the Tools menu.

On the Theme File Editor screen, search for the functions.php file on the right panel and click it to edit it.

Paste the above code snippet right after the last line of the file content and click the Update File button.

Functions.php file in WordPress

Same as the first method, the above code will place the last modified post at the top order.

You can replace the desc parameter on the 5th line with asc to place the post you edited earliest at the top order.

Adding the Code via functions.php File vs Custom Plugin

While I demonstrated how to add the code snippet by editing the functions.php file, I personally suggest you add the custom code by using a custom plugin.

Why?

Because the content of the functions.php file will be overridden every time you update your theme (unless you use a child theme), requiring you to re-add the code after updating.

With a custom plugin, you can update your theme without needing to worry about the custom functions you have added.

Using a custom plugin is also beneficial if you want to add another custom function in the future. You can simply edit the plugin file to add it. You can use the PHP comments to separate between custom functions in the file.

Custom plugin file

Summary

In WordPress, posts are sorted chronologically by default. There is no built-in option to sort posts by modification date. There are two approaches you can use to add the functionality.

First, you can edit the URL of the Posts screen. Second, you can edit the functions.php file of your theme for a permanent solution.

If you prefer the latter solution, make sure that your hosting service offers a daily backup feature so that you can simply restore your website in case everything doesn’t go as per expectation.

If your hosting doesn’t offer daily backups, make sure to create a backup of your website first every time you want to edit the functions.php file of your theme.

Or at least you create the backup of the functions.php file itself so that you can restore the original file when the custom code you add leads to an issue.

This page may contain affiliate links, which help support the project. Read our affiliate disclosure.

Aliko Sunawang

Aliko is a professional blogger and web creator. He has been blogging with WordPress since 2013. In his spare time, he loves going out to take some photos. More

You can’t live on Mars

But you can definitely boost your site traffic with SEO.

new

Got a website?

You might need this cool content to boost your organic traffic from Google.

Where should we send the template?

Thanks! Please check your inbox to confirm.