How to add Last Modified Column to Page and Post Lists

WordPress sort pages by modified date. The Last Modified column will be sortable, allowing you to order the posts or pages by latest or oldest. How to add update date & time in my wp site? The following code shows how to add a Last Modified column to the page and post lists in WordPress Website.

This way you can easily enable & disable the customizations and keep them when you update or replace your theme. Please follow the below instruction, just copy below code & place your function.php file

Show Code for Last Modified Column to Page and Post Lists

// Add the custom column to the post type
add_filter( ‘manage_pages_columns’, ‘ithelpsbd_add_custom_column’ );
add_filter( ‘manage_posts_columns’, ‘ithelpsbd_add_custom_column’ );
function ithelpsbd_add_custom_column( $columns ) {
$columns[‘modified’] = ‘Last Modified’;

return $columns;
// Add the data to the custom column
add_action( ‘manage_pages_custom_column’ , ‘ithelpsbd_add_custom_column_data’, 10, 2 );
add_action( ‘manage_posts_custom_column’ , ‘ithelpsbd_add_custom_column_data’, 10, 2 );
function ithelpsbd_add_custom_column_data( $column, $post_id ) {
switch ( $column ) {
case ‘modified’ :
$date_format = ‘Y/m/d’;
$post = get_post( $post_id );
echo get_the_modified_date( $date_format, $post ); // the data that is displayed in the column
// Make the custom column sortable
add_filter( ‘manage_edit-page_sortable_columns’, ‘ithelpsbd_add_custom_column_make_sortable’ );
add_filter( ‘manage_edit-post_sortable_columns’, ‘ithelpsbd_add_custom_column_make_sortable’ );
function ithelpsbd_add_custom_column_make_sortable( $columns ) {
$columns[‘modified’] = ‘modified’;

return $columns;
// Add custom column sort request to post list page
add_action( ‘load-edit.php’, ‘ithelpsbd_add_custom_column_sort_request’ );
function ithelpsbd_add_custom_column_sort_request() {
add_filter( ‘request’, ‘ithelpsbd_add_custom_column_do_sortable’ );
// Handle the custom column sorting
function ithelpsbd_add_custom_column_do_sortable( $vars ) {
// check if sorting has been applied
if ( isset( $vars[‘orderby’] ) && ‘modified’ == $vars[‘orderby’] ) {

// apply the sorting to the post list
$vars = array_merge(
‘orderby’ => ‘post_modified’
return $vars;

​Leave a Comment

Comment authors age:

svg sorry this file type is not permitted for security reasons

How to build a cheap business website using WordPress