In my WP Plugin I have made an error handler. It works so far but I'd like to not echo in admin_notices, but have that nice little message box of wordpress if sth is going wrong:

red box

How can I do so?


All you need is the correct html markup, namely a paragraph p inside a container div with a certain class. Usable classes are updated green, error & notice-error red, notice-warning orange, notice-info blue. Exemplary usage:

add_action( 'admin_notices', 'wpse330943_admin_notices' );
function wpse330943_admin_notices() {
  <div class="notice notice-error">
      //some text

In the admin_notices doc they tell how to do so
I just found it...

  • The Settings API has some functions for error handling that can be used to generate messages. – Nicolai Mar 7 at 10:51
  • @Nicolai It didn't work ... I may made sth wrong, but since this works out I won't try again now – A new 1 Mar 7 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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