How to Add Dismissible WordPress Admin Notices

Note: As of WordPress 4.2, dismissible WordPress admin notices should be a part of WordPress core. More information can be found here.

I find that in my blogging workflow, I tend to save drafts often so that I don’t lose my work.

While this may add a second or two here and there, the peace of mind that I get from knowing that I won’t lose all of my work is definitely worth it.

But, there is one little thing that bothers me about saving drafts, and that is the pesky WordPress admin notices that stay at the top of the view.

So, today I set out to find a way to hide or remove the WordPress admin notices.

Initially, I tried a solution that automatically hid the “Post Draft Updated” WordPress admin notice after 5 seconds, but I wasn’t very fond of the UX.

After a bit of thought, I decided that the user should be able to actually dismiss these notices and decided upon this:

Dismissible WordPress Admin Notices

The Magic Behind Dismissible WordPress Admin Notices

Plugin Name: Dismissible WordPress Admin Notices
Plugin URI:
Description: Adds the ability to dismiss WordPress admin notices.
Author: ebinnion
Version: 0.1
Author URI:
class Dismissable_Admin_Messages {
    public function __construct() {
        add_action('current_screen', array(
    public function admin_init() {
        $screen = get_current_screen();
        $showOn = array(
        if (in_array($screen->id, $showOn)) {
            if (isset($_GET['message'])) {
                add_action('admin_head', array(
                add_action('admin_footer', array(
    public function admin_head() {
        #message {
        position: relative;

        #message .dashicons-no {
        cursor: pointer;
        margin-top: -.5em;
        position: absolute;
        right: 10px;
        top: 50%;
        <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->
    public function admin_footer() {
        (function( $ ) {
        var message = $( '.wrap > #message' );
        message.append( 'dashicons-no">' );
        message.find( '.dashicons-no' ).on( 'click', function() {
        } );
        })( jQuery );
        <!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"--

new Dismissable_Admin_Messages();

How to Install

As of now, this plugin isn’t on the official WordPress repository. But, if you would like to use this functionality, you can save the code above into a file and put it in either:

  • wp-content/plugins
  • wp-content/mu-plugins

If you have any questions, please don’t hesitate to ask.

4 responses to “How to Add Dismissible WordPress Admin Notices”

  1. Hi man, if your plug in work i love you!!! i will try it later today… really dont know why there is not a option directly in wordpress to dismiss all those notification, me too i save draft a lot and is really annoying, and push down a line the article windows.

    1. Hello Antonio,

      As of WordPress 4.2 (the latest release at this point), dismissible WordPress admin notices are baked in to WordPress core. So, you shouldn’t need to use my plugin anymore.

      That being said, thanks for commenting and getting me to update this post.

      Here’s some more information about dismissible WordPress notices in 4.2:

  2. Great article! Thanks for sharing. I’ve created a small script that helps you add dismissible/static admin notifications to WordPress. Hope you’ll find it useful. You can see the project on GitHub

    1. Thanks for the link Yoav. Your project looks interesting!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.