"Last Updated" Column in the Network Sites List
Adds a sortable-looking "Last updated" column to Network Admin > Sites so you can spot sites nobody has touched in months.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_filter( 'wpmu_blogs_columns', function ( $columns ) {
$columns['wpide_last_updated'] = __( 'Last updated' );
return $columns;
} );
add_action( 'manage_sites_custom_column', function ( $column, $blog_id ) {
if ( 'wpide_last_updated' !== $column ) {
return;
}
$site = get_site( $blog_id );
if ( ! $site || '0000-00-00 00:00:00' === $site->last_updated ) {
echo '—';
return;
}
$time = strtotime( $site->last_updated . ' UTC' );
printf(
'<span title="%1$s">%2$s</span>',
esc_attr( wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time ) ),
/* translators: %s: human time difference */
esc_html( sprintf( __( '%s ago' ), human_time_diff( $time ) ) )
);
}, 10, 2 );
Notes
The date comes from the site's last_updated field, which WordPress refreshes when content is published.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.