andrezrv
10/14/2013 - 11:38 PM

How to display a notice in the admin section of WordPress.

How to display a notice in the admin section of WordPress.

<?php

/**
 * Displays a notice in the admin section under some condition. 
 *
 * @author andrezrv
 */
function my_admin_notice() {

	global $current_screen;

	if ( $current_screen->parent_base == 'options-general' ) { // Or whatever.

		$html = '<div class="error"><p><strong>OMFG!</strong> Something really really bad just happened! D:</p></div>';
		echo $html;

	}

}

add_action( 'admin_notices', 'my_admin_notice' );