Display Admin Notices in custom locations in the WordPress Dashboard
If you’ve used WordPress for a while, you’re probably familiar with the nice-looking notices (warnings and errors) that appear at the top of various admin pages:
These notices are great for posting generic information relevant to a particular page up near the top, where they’ll be easily seen. But what if you want to use the .updated and .error classes to create messaging in other parts of the page? If you just add markup, it will move up to the heading of the page, because of the following JS that runs in wp-admin/js/common.js:
// Move .updated and .error alert boxes. Don't move boxes designed to be inline. $('div.wrap h2:first').nextAll('div.updated, div.error').addClass('below-h2'); $('div.updated, div.error').not('.below-h2, .inline').insertAfter( $('div.wrap h2:first') );
This explains why messages get pushed to the top of the window regardless of where they are actually placed in the server-side markup. Also, it proveds a really easy way to put the message where you want it: just add a class of .inline and your message will stay where you want it.