Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
doubleonestudio opened this issue Mar 7, 2024 · 2 comments

Comments

@doubleonestudio
Copy link

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.

@joshuadavidnelson
Copy link
Owner

joshuadavidnelson commented Mar 7, 2024

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!

@doubleonestudio
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants