25

How to Hide Admin Notifications in WordPress (Excluding Dashboard)

Powered by WPCodeBox

Effortlessly remove WordPress plugin notifications from all admin pages, ensuring a cleaner, more focused dashboard experience. Hide annoying alerts everywhere except your main WP Admin dashboard.


<?php 

add_action( 'current_screen', function() {
    
	$screen = get_current_screen();

	if ( $screen->id !== "dashboard" ) {
        add_action( 'admin_enqueue_scripts', function() {
            
            echo '<style>
                    div.wrap > .update-nag, 
                    div.wrap > .updated, 
                    div.wrap > .error, 
                    div.wrap > .is-dismissible 
                    { 
                        display: none !important; 
                    }
                 </style>';
        
        });
	}
});

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.