Hide Admin List Columns by Default
Hides less useful columns for users who have not customized Screen Options yet. Anyone can still turn them back on.
Opens WPIDE on
Code
// Screen ID => columns hidden until the user changes Screen Options.
$wpide_default_hidden_columns = array(
'edit-post' => array( 'tags', 'comments' ),
'edit-page' => array( 'comments', 'author' ),
'users' => array( 'posts' ),
);
add_filter( 'default_hidden_columns', function ( $hidden, $screen ) use ( $wpide_default_hidden_columns ) {
if ( $screen && isset( $wpide_default_hidden_columns[ $screen->id ] ) ) {
$hidden = array_unique( array_merge( (array) $hidden, $wpide_default_hidden_columns[ $screen->id ] ) );
}
return $hidden;
}, 10, 2 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.