Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

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.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Admin area
  • Tested with WordPress 7.1
PHP
<?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.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.