Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andrezrv
Last active December 25, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrezrv/6984145 to your computer and use it in GitHub Desktop.
Save andrezrv/6984145 to your computer and use it in GitHub Desktop.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment