I found the following code at bytefreaks.net. It adds a sort-able column to edit.php, but the column appears only on Posts and not on Pages (...?post_type=page)
bytefreaks suggested putting it in functions.php but I wanted to avoid update problems so I installed the "My Custom Functions" plugin and put the code there.
I don't know WordPress well enough to fully understand each function. Can anyone tell me what I need to do to make this code work for Pages as well as Posts?
// Register the column
function post_modified_column_register( $columns ) {
$columns['post_modified'] = __( 'Modified', 'mytextdomain' );
return $columns;
}
add_filter( 'manage_edit-post_columns', 'post_modified_column_register' );
// Display the column content
function post_modified_column_display( $column_name, $post_id ) {
if ( 'post_modified' != $column_name ){
return;
}
$post_modified = get_post_field('post_modified', $post_id);
if ( !$post_modified ){
$post_modified = '' . __( 'undefined', 'mytextdomain' ) . '';
}
echo $post_modified;
}
add_action( 'manage_posts_custom_column', 'post_modified_column_display', 10, 2 );
// Register the column as sortable
function post_modified_column_register_sortable( $columns ) {
$columns['post_modified'] = 'post_modified';
return $columns;
}
add_filter( 'manage_edit-post_sortable_columns', 'post_modified_column_register_sortable' );