Prevent Manual Admin Notices From Being Moved to the Top

Sometimes you want to style a paragraph or something with notice-warning, notice-error, etc, but it’s just regular part of a screen, not something that should live at the top in actual the admin_notice area. For example:

Screenshot of wp-admin screen where a notice appears as the third paragraph of text on the screen, rather than at the top before everything else.

By default, WP will automatically move the notice from it’s original location and place it in the area that it would be placed in if it were added via the admin_notices action.

You can prevent from happening by adding the wp-header-end CSS class to an element before the notice. WP’s CSS applies visiblity: hidden to the wp-header-end element, so you’ll probably just want to make it an empty span or something

Leave a Reply

Your email address will not be published. Required fields are marked *