Last modified column in the posts list
Adds a sortable “Last modified” column to posts and pages, so you can see what was updated recently.
<?php
add_action(
'admin_init',
static function () {
foreach ( array( 'post', 'page' ) as $type ) {
add_filter(
"manage_{$type}_posts_columns",
static function ( $columns ) {
$columns['snipfire_modified'] = __( 'Last Modified' );
return $columns;
}
);
add_filter(
"manage_edit-{$type}_sortable_columns",
static function ( $columns ) {
$columns['snipfire_modified'] = 'modified';
return $columns;
}
);
add_action(
"manage_{$type}_posts_custom_column",
static function ( $column, $post_id ) {
if ( 'snipfire_modified' === $column ) {
echo esc_html( get_the_modified_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $post_id ) );
}
},
10,
2
);
}
}
);
In these packs
- More admin tweaks: Useful columns, a tidier admin bar, a welcome box for clients, and fewer menus for editors.