admin_notices | Hook | WordPress Developer Resources

April 13, 2021

Prints admin screen notices.

Example #Example

In order to display a notice, echo a div with the class notice and one of the following classes:

* notice-error – will display the message with a white background and a red left border.
* notice-warning– will display the message with a white background and a yellow/orange left border.
* notice-success – will display the message with a white background and a green left border.
* notice-info – will display the message with a white background a blue left border.
* optionally use is-dismissible to add a closing icon to your message via JavaScript. Its behavior, however, applies only on the current screen. It will not prevent a message from re-appearing once the page re-loads, or another page is loaded.

Don’t use update-nag as a class name!
It is not suitable for regular admin notices, as it will apply different layout styling to the message. Additionally it will trigger the message to be moved above the page title (

), thus semantically prioritizing it above other notices which is not likely to be appropriate in a plugin or theme context.

The inner content of the div is the message, and it’s a good idea to wrap the message in a paragraph tag

for the correct amount of padding in the output.

function sample_admin_notice__success() { ?>

%2$s