Table of Contents

How to remove admin notices from specific pages?

In this article, I will show how to remove WordPress admin notices from a specific page. Below the code

If theme then add code in functions.php file or If plugin then add code in plugin file



function hrm_remove_admin_notice(){
  	
  	// First make a array with page slug
	$pages = [
		
		'innovs_all_settings',
		'admin_general_setting',
		'admin_attendance_setting',
		'admin_message_setting'
	];

	if(isset($_GET['page'])){
		if( in_array( $_GET['page'], $pages) ){
			remove_all_actions( 'user_admin_notices' );
			remove_all_actions( 'admin_notices' );
		}
	}
	
}

add_action('in_admin_header', 'hrm_remove_admin_notice', 99);
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Leave a Comment

Your email address will not be published.

Related Posts