Prevent Manual Admin Notices From Being Moved to the Top

Sometimes you want to style an element with notice-warning, notice-error, etc, but it’s just regular part of a screen, not something that should live at the top in 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 that from happening by adding the inline CSS class to the element.

<div className="notice notice-error inline">
	<p>
		Lorum ipsum...
	</p>
</div>

Leave a Reply

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