Guest User

Untitled

a guest
Jan 24th, 2013
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /************************************************************\
  2. * LAST MODIFIED COLUMN IN /ADMIN
  3. \************************************************************/
  4. function add_last_modified_column($columns) {
  5.     return array_merge( $columns,
  6.               array("last_modified" => __("Last Modified")) );
  7. }
  8. add_filter("manage_posts_columns" , "add_last_modified_column");
  9.  
  10. function last_modified_column( $column, $post_id ){
  11.   if( ! "last_modified" == $column ) {
  12.   the_modified_time('F j, Y');
  13.   }
  14. }
  15.  
  16. add_action( "manage_posts_custom_column" , "last_modified_column", 10, 2 );
  17.  
  18. function last_modified_column_register_sortable( $columns ) {
  19.     $columns["last_modified"] = "last_modified";
  20.  
  21.     return $columns;
  22. }
  23.  
  24. add_filter( "manage_edit-post_sortable_columns", "last_modified_column_register_sortable" ); // replace "post" with the slug of your custom post type
  25.  
  26. function sort_column_by_modified( $vars ){
  27.     if ( isset( $vars["orderby"] ) && "last_modified" == $vars["orderby"] ) {
  28.         $vars = array_merge( $vars, array(
  29.             "orderby" => "modified"
  30.         ) );
  31.     }
  32.     return $vars;
  33. }
  34. add_filter( "request", "sort_column_by_modified" );
RAW Paste Data