Skip to main content
Use get_query_var( 'post_status' ) instead of $_GET['post_status']
Source Link
Dave Romsey
  • 17.9k
  • 11
  • 55
  • 70

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.
    if ($status != issetget_query_var( $_GET['post_status']'post_status' );
 ||   if ( 'trash' !== $_GET['post_status']$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' );

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.
    if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_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' );

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' );
Source Link
Dave Romsey
  • 17.9k
  • 11
  • 55
  • 70

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.
    if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_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' );