How To Show The Time For Scheduled Posts

How To Show The Time For Scheduled Posts

When scheduled posts are listed in the WordPress admin interface, only date is displayed.

If you post to regular time-slots then being able to see the scheduled time as well as the date without having to go into the post edit screen can save a lot of a time.

In this short article, I’ll show how to add the time to the post listing for scheduled posts.

Screen grab of a row from the post listing page with the new scheduled time highlighted
Having the time for a scheduled post in the post listing saves a lot of clicking

Publishing to a regular schedule is one those “must-do” rules for successful blogging. At WPMU Dev we use three set time-slots per day and with multiple authors being able to see who has already scheduled a post for a time-slot saves a lot of messing about as well as reducing the likelihood of scheduling two posts for the same slot.

By default, though, the post listing page in the admin interface shows only the date for scheduled posts. So, we’ll write a very simple function to display the time.

Find the Appropriate Filter

As with all WordPress tweaks, it’s just a matter of finding the appropriate filter or action to hook into. In cases like these, it can often take longer to find the filter than to write the code!

Our filter of choice is post_date_column_time which gets called just before WordPress writes the date and time for the post to the listing table.

The Code

Using this filter, we’ll check to see if the current post is scheduled by testing if the post_status is set to future.  If it is scheduled, we’ll get the post time and add it to the current column text otherwise we’ll just leave the column text as is.

Here’s the code:

// Custom function to add time to the date / time column for future posts
function sst_post_date_column_time( $h_time, $post ) {
// If post is scheduled then add the time to the column output
if ($post->post_status == ‘future’) {
$h_time .= ‘<br>’ . get_post_time( ‘g:i a’, false, $post );
// Return the column output
return $h_time;
add_filter ( ‘post_date_column_time’ , ‘sst_post_date_column_time’ , 10 , 2 );

Notice that the add_filter statement specifies both the priority (10) and the number of arguments (2). We need to specify the arguments so that the $post variable is passed, otherwise just the column text ($h_time) will be passed.

Just a few lines of code to add a really useful feature. You can just add the code to your functions.php but the preferred option is to add the standard header and install it as a plugin.

What else is missing from the post listing? Put your thoughts in the comments below.