How to Add a Sortable “Last Updated” Column in WordPress Admin Posts List
If you’re managing a blog or website with regularly updated content, it’s helpful to quickly see when each post was last modified. By default, WordPress shows only the publish date in the admin panel, but you can easily add a “Last Updated” column and make it sortable with a few lines of code.
In this tutorial, I’ll show you how to add a Last Updated column in the Posts > All Posts screen of your WordPress admin dashboard.
💡 Don’t worry! This is beginner-friendly. You can copy and paste the code below into your theme’s
functions.php
file or use a code snippets plugin like Code Snippets to avoid editing theme files directly.
Step-by-Step Code to Add the “Last Updated” Column
1. Add the column to the Posts list
This function adds a new column titled “Last Updated” to the posts list in the WordPress admin.
2. Display the last modified date in the new column
Here, we populate the column with the modified date of each post using get_the_modified_date()
.
3. Make the column sortable
We tell WordPress to allow sorting on this new column by mapping it to the post_modified
field.
4. Adjust the query to sort by the last modified date
This step makes the sorting actually work when you click the “Last Updated” column heading.
🔍 How It Works (In Simple Terms)
Let’s break it down:
-
manage_posts_columns
: Adds a new column to the posts table. -
manage_posts_custom_column
: Fills that column with data (in this case, the last updated date). -
manage_edit-post_sortable_columns
: Lets WordPress know the column is sortable. -
pre_get_posts
: Modifies the admin query to sort based on thepost_modified
date when sorting is triggered.
✅ Final Result
After you add this code:
-
You’ll see a new column labeled “Last Updated” next to your post titles.
-
You can click on it to sort posts from the most recently updated to the oldest — and vice versa.
🛡️ Bonus Tips
-
Use a child theme or the Code Snippets plugin to keep changes safe during theme updates.
-
You can use the same technique for other post types like Pages or Custom Post Types — just replace
manage_posts_columns
with the corresponding hook (e.g.,manage_page_columns
).
🙋 Need Help?
If you’re new to adding code in WordPress or want help extending this to Pages or Custom Post Types, feel free to leave a comment or reach out!