Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On edit.php, the main content is a list of posts, with columns including the published date.

I'd like to change the date format of the published date just on the admin page. In this case, I don't want to change what the users see; I want to change what the admin sees.

I want to add the day of the week to the published/scheduled date, because I'm planning to publish "Every Tuesday, at least," and want to make sure I've scheduled posts correctly.

After searching, the best route seems like it would be to create a custom field, but if there's a more subtle way to do this, I'd prefer to not install the custom field plugin.

edit: thanks to Bainternet's comment, I see that I already have custom fields (the option was just hidden by default). And, I see custom fields are not what I want. The data already exists; I just want to format it differently on the screen.

share|improve this question
    
Custom fields are built-in the WordPress core so you don't have to install any plugin –  Bainternet Jun 4 '11 at 12:58
    
ah; sorry, I hadn't read far enough to see "Custom Fields are hidden by default if they have not been used before." I'm still optimistic I can change the format and not actually add a new field. –  Thunder Rabbit Jun 4 '11 at 13:50

3 Answers 3

up vote 4 down vote accepted
  1. Add a column to the post edit screen and format the date however you like.

  2. Remove the default Date column.

EDIT here's the code to put inside your theme's functions.php file:

EDIT 2 added additional code to add publish status and make the column sortable, this should now be a complete copy of the original date column.

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' );

Thanks to Scribu for his tutorial on sortable columns

share|improve this answer
    
I've been super busy at work and haven't taken time to try this, but it seems like it won't work. Step one above adds a new column with new data, right? Wouldn't I need to recreate the functionality of the default Date column? (so it shows up as the published date of the post) –  Thunder Rabbit Jun 8 '11 at 16:27
    
@Thunder Rabbit - see update with code above. –  Milo Jun 8 '11 at 17:06
    
@Thunder Rabbit - 2nd update, added more code. –  Milo Jun 8 '11 at 17:46
    
Fantastic!! The only fault I can find is not telling me where it should go. Hmph! making me do research... ;-) (I've edited your answer above to add the key ingredient) –  Thunder Rabbit Jun 9 '11 at 6:00
    
I just updated to 3.2 and don't have time to implement my old hack again, but I don't have to: Your code continues to work beautifully. Thank you. Thank you. Dear everyone! DON'T HACK CORE FILES!! –  Thunder Rabbit Jul 10 '11 at 2:23

for more info, have a read of this WP codex article: http://codex.wordpress.org/Formatting_Date_and_Time

share|improve this answer
1  
doesn't this just format the date and time as the user sees it? I want to format the publish date as I see it on the back end. (on edit.php) –  Thunder Rabbit Jun 8 '11 at 16:29

DON'T HACK CORE FILES! There really is an easy way to do the small change you're thinking of doing!

Ignore my original answer:

The change I want is so easy that I am hacking the core files.

I can simply add "l " to the format string of $post->post_date in wp-admin/includes/class-wp-posts-list-table.php each and every time I update, until the accumulated number of hours spent making that little change add up to more than figuring out how to do it with a plugin/widget/template/hook and implementing that.

I'm not going to accept my answer for now; I hope someone can still thank Milo, who showed me the right way to do it!

share|improve this answer
    
Super thanks to Milo for showing me the right way. I'm impressed with Wordpress (and Milo)! –  Thunder Rabbit Jun 9 '11 at 6:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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