Turn Off Avatars in the Dashboard Only
Stops wp-admin from loading an avatar for every row of the comments and users screens and the dashboard, which saves dozens of requests to Gravatar, while avatars keep showing on the front of the site.
Opens WPIDE on
Code
add_filter( 'pre_option_show_avatars', function ( $value ) {
if ( ! is_admin() || wp_doing_ajax() ) {
return $value;
}
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
if ( $screen && $screen->is_block_editor() ) {
return $value;
}
return '0';
} );
Notes
The block editor and front-end comment lists are not affected.
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.