In the list of posts in the 'All Posts' screen, is there a way to display both date -and- time in the Date column? If you hover over the date, the time is part of abbr tag title, but I'd like to display the time, directly. I see that I could unset the current Date column and put in a custom Date column. Just wondering if there is a simpler solution to show the time, since it's already there in the abbr tag?
2 Answers
Add this code to functions.php
of your active theme:
function wpse_posts_list_date_format( $time, $post ) {
return $post->post_date;
}
add_filter( 'post_date_column_time', 'wpse_posts_list_date_format', 10, 2 );
The callback function receives 4 parameters, but we need only 2.
-
I'm sure the first js solution, above, would have worked, but the post_date_column_time filter solution provided more flexibility in formatting. Instead of returning the simple $post->post_date, I used the get_post_time function to customize the date and time formats. Thank you. Commented Oct 16, 2017 at 21:15
You can do it with some JavaScript:
jQuery(".column-date abbr").each(function(){
jQuery(this).html(jQuery(this).attr("title").replace(" ", "<br/>"));
jQuery(this).removeAttr("title");
});
This will replace visible date portion with date and time and will clear the title attribute.
-
Please check your script. It does nicely replace date from title attribute, but it does not make title empty, afterwards.. Commented Oct 16, 2017 at 20:45