2

How would I go about adding a column to the Page Admin area that would show the last revision date of all pages? Alongside the Author and Published Date columns?

I need to keep an eye on the page edits that other users do, and right now, the Page Admin area will only show the published date for a published page and the last modified date of a draft. So I need to show the revision date by any user of each published page.

Possibly complicating things is I have post/page revisions disabled in wp-config.php to keep the database down to size, so an action can't hook into already existing page revision metadata.

But the database contains a post_modified_gmt metadata column, so can that be grabbed by a direct database query? Not a good idea? And would I use this kind of action? http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column

4

Would need some prettifying, but basic code is following:

add_filter('manage_pages_columns', 'add_revised_column');
add_action('manage_pages_custom_column', 'echo_revised_column', 10, 2);

function add_revised_column($columns) {

    $columns['revised'] = 'Revised';

    return $columns;
}


function echo_revised_column($column, $id) {

    if ('revised' == $column)
        echo get_post_field('post_modified', $id);
}
  • Works great, thanks. I will look into core WP to see if I can figure out how to add the click to sort column function and change the date format, too. – markratledge Apr 1 '11 at 17:17
  • 1
    @songdogtech I remembered scribu had post on custom columns and making them sortable – Rarst Apr 1 '11 at 17:29
  • What file do you add this code? – Amesey Oct 9 '15 at 10:33
  • @Amesey any that makes sense to your use case (theme's functions.php, plugin, etc). – Rarst Oct 9 '15 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.