WordPress.org

Ready to get started?Download WordPress

Forums

How to make trashed posts show post_modified instead of post_date (3 posts)

  1. Bonesnap
    Member
    Posted 1 year ago #

    Hey all,

    A client has a very specific request and my Googling hasn't come up with any results.

    The client wants the trashed posts (of a specific custom post type) to show their modified date instead of the creation date when listed in the back-end of WordPress. The post_modified is updated when you change its status from publish to trash so this should be accurate.

    I was wondering which hook to investigate or even a source file that I can change to accommodate this. As mentioned before, I have Googled for an answer but haven't come up with anything.

    Any help or insight is greatly appreciated. Thanks!

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    Try it with the 'post_date_column_time' hook if it's the date shown in the "Date Column". Something like this:

    add_filter( 'post_date_column_time', 'trash_time_column', 10, 4 );
    function trash_time_column( $h_time, $post, $column_name, $mode ) {
    	// change the post_type to your post type
    	if ( ( $post->post_status == 'trash' ) && ( $post->post_type == 'post' ) ) {
    		$post_modified = mysql2date( __( 'Y/m/d' ), $post->post_modified );
    		return  $post_modified;
    	}
    
    	return $h_time;
    }
  3. Bonesnap
    Member
    Posted 1 year ago #

    Thanks for the quick reply. I'm going to give this a shot and I'll post my results.

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic