You can check the value of the post_status
query variable and make sure that it's set to trash
:
function wpse239286_trash_column( $columns ) {
// Bail if we're not looking at trash.
$status = get_query_var( 'post_status' );
if ( 'trash' !== $status ) {
return $columns;
}
return array_merge( $columns,
array( 'trash_column' => __( 'Trash Column', 'text-domain' ) )
);
}
add_filter( 'manage_posts_columns' , 'wpse239286_trash_column' );
add_filter( 'manage_pages_columns' , 'wpse239286_trash_column' );