archived-post-status icon indicating copy to clipboard operation
archived-post-status copied to clipboard

Archiving changes Date field to "Last Modified" instead of "Published"

Open doubleonestudio opened this issue 11 months ago • 2 comments

After changing a post from Published to Archived, I noticed that on the "All [Post-types]" list view, the post's entry in the "Date" column changes from reading "Published [date]" to "Last Modified [date]". The date itself is not changed from the initial date of publishing; accordingly, is it possible to keep this date labeled as "Published" for the sake of clarity?

Our site needs to keep a record of when posts were initially published as well as when they were archived/last modified, so I am using the "WP Last Modified Info" plugin in conjunction with yours. However, having the published date relabeled as "last modified" may lead to confusion for some users. I tried disabling the other plugin to see if it was having any sort of interactions with yours, but the issue was unchanged.

doubleonestudio avatar Mar 07 '24 01:03 doubleonestudio

Hey @doubleonestudio thanks for reaching out about this! The way WordPress core determines the label for the date, it defaults to "last modified" unless the post status is "Published," so this behavior is expected in core.

Also, since users can archive a post from other statuses (e.g. draft, pending, etc), not all archived content is necessarily published before being archived, so a "Published" label doesn't work across the board.

All that said, I think this would be good to include where the previous status was Published. I'm working on the next version of the plugin, which will include a new "Archived date" column and save the previous status of archived content, so I'll look at adding this label logic where it makes sense.

In the meantime, if you want to change this label on all archived content on your site, you can filter it with the post_date_column_status filter

Some like this (warning: this is untested code)

add_filter( 'post_date_column_status', function( $status, $post, $column ) {

    // first confirm this is the correct column and an archived post
    if ( 'date' === $column && isset( $post->post_status ) && 'archive' === $post->post_status ) {
        $status = __( 'Published' );
    }

    return $status;

}, 10, 3 );

Hope that helps!

joshuadavidnelson avatar Mar 07 '24 17:03 joshuadavidnelson

Thanks so much for the explanation; I suspected it might have something to do with that, but I wasn't sure. A new "Archived date" column would be a great addition.

I added the filter you suggested, and so far it seems to be working perfectly. I will update if I notice any unforeseen bugs. Thanks again!

doubleonestudio avatar Mar 07 '24 23:03 doubleonestudio