WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use javascript to add a notice to the top of the wordpress page just like they do when auto-saving the page. But in looking at the DOM, I don't see any special div that I could find to add my notice to:


<div class="wrap">
    <h2>Edit Page <a href="http://my-site.com/wp-admin/post-new.php?post_type=page" class="add-new-h2">Add New</a></h2>
    <div style="display: block;" id="local-storage-notice" class="hidden updated">
        <p class="local-restore">
            The backup of this post in your browser is different from the version below. <a class="restore-backup" href="#">Restore the backup.</a>
        <p class="undo-restore hidden">
            Post restored successfully.     <a class="undo-restore-backup" href="#">Undo.</a>

Is there a javascript function wordpress has that I can use?

share|improve this question

Look at F:\sites\wp-git\wp-admin\js\common.js:

$('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );

If your notice has the class updated or error, it will be set after the first h2 automatically. When you create custom messages, make sure you are using one of these classes. Then you can just append them to body, and WordPress will move them to the proper place.

share|improve this answer
Thanks. Do you know if those classes and divs have been there since 3.0? I don't want to rely on anything that's not documented and could change. – Don Rhummy Apr 22 '14 at 5:18
@DonRhummy They are very old, and they will probably not change, because that would break too many plugins. – toscho Apr 22 '14 at 7:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.