Include last modified date on posts and page columns

Norcross Jul 10th, 2013adminfunctions file

While publish date and author are useful (and often needed), sites with a larger editorial process and multiple people involved may need a bit more information. While the data is usually available in the individual post editor (if enabled), it can be hard to tell at a glance what’s been updated, when, and by whom. The functions below will add an extra column to the posts and / or page columns to display the last modified date and the user who did. The only real difference is the label in the add_action hook, as posts and pages are treated differently. Also, the functions calling the column data are separated because different functions are required for hierarchical post types and non-hierarchical types.

Post Columns

Page Columns

11 Responses to “Include last modified date on posts and page columns”

  1. Andrew

    Hello – thank you for this! Much appreciated. Is there any way to make it sortable like the Title and Date columns?

    • Norcross

      I’ve seen some code for that around, but it involves more stuff behind the scenes (i.e. involves special queries)

  2. Aaron

    How would you modify this to work for a custom post type? I have it showing a column by changing ‘manage_edit-page_columns’ to ‘manage_edit-CUSTOMPT_columns’ but no data comes out. I think I need to just clarify where its getting the data for get_post_field, like by calling a post type, but no idea where to do that.
    Any thoughts?

    • Jay

      But thats all we need to do for getting it work for custom post type. I need to do it for my “product” custom post type and it works fine. Here is my codes:

      add_action ( ‘manage_posts_custom_column’, ‘rkv_post_columns_data’, 10, 2 );
      add_filter ( ‘manage_edit-product_columns’, ‘rkv_post_columns_display’ );

      I just replaced this and it works for me

  3. Matthew Douglas

    Hey bud – this is awesome if you could make this sortable by last modified date and turned it into a plugin – I’d buy a copy in a second.

    • Heather

      Mathew, I was able to make them sortable by adding this after the code from above:

      function last_modified_column_register_sortable( $columns ) {
      $columns["modified"] = "last_modified";
      return $columns;
      add_filter( "manage_edit-post_sortable_columns", "last_modified_column_register_sortable" );
      add_filter( "manage_edit-page_sortable_columns", "last_modified_column_register_sortable" );

  4. Scott

    This code worked, thank you, it was exactly what we needed to see what a client had changed on a site after we cloned it for redevelpoment. What a tlme saver

    So… I asked my programmer to make it a plugin, and she found one had been done – – tested it, and it works too (WP 3.91)

  5. Damien Carbery

    Thanks for this code – nice and simple.

    I changed the date and time to be the format in Settings/General:
    `$modified = date(‘n/j/y @ g:i a’, $m_stamp );`
    `$modified = date(get_option( ‘date_format’ ).’ @ ‘.get_option( ‘time_format’ ), $m_stamp );`

    The functions calling the column data are identical (content and parameters) – though the post says that different functions are required for “hierarchical post types and non-hierarchical types”. Did I mis-diff the code?

    • Norcross

      good catch on using the date_format option. that’s better. as for the hierarchical / non-hierarchical differences, it’s subtle, but there. the first part of the hook and filter names are what is different.