- Add a column to the post edit screen 并根据您的喜好设置日期格式。
- Remove the default Date column.
EDIT 下面是要放入主题中的代码
functions.php
文件:
EDIT 2 添加了其他代码以添加发布状态并使列可排序,现在这应该是原始日期列的完整副本。
function my_custom_columns( $columns ) {
unset( $columns[\'date\'] );
$columns[\'mydate\'] = \'My Custom Date\';
return $columns;
}
function my_format_column( $column_name , $post_id ) {
if($column_name == \'mydate\'){
echo get_the_time( \'l, F j, Y\', $post_id )."<br>".get_post_status( $post_id );
}
}
function my_column_register_sortable( $columns ) {
$columns[\'mydate\'] = \'mydate\';
return $columns;
}
function my_column_orderby( $vars ) {
if ( isset( $vars[\'orderby\'] ) && \'mydate\' == $vars[\'orderby\'] ) {
$vars = array_merge( $vars, array(
\'orderby\' => \'date\'
) );
}
return $vars;
}
function my_column_init() {
add_filter( \'manage_posts_columns\' , \'my_custom_columns\' );
add_action( \'manage_posts_custom_column\' , \'my_format_column\' , 10 , 2 );
add_filter( \'manage_edit-post_sortable_columns\', \'my_column_register_sortable\' );
add_filter( \'request\', \'my_column_orderby\' );
}
add_action( \'admin_init\' , \'my_column_init\' );
感谢
Scribu 为他的
tutorial on sortable columns