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'm new to Wordpress and trying to take advantage of the framework as much as possible. On the front end, I want a centralized message area to display error, success, and general notices similar to how they're handled via admin_notices on the back end. I'm not seeing a similar hook for the front end.

I guess I'm asking which action should I be hooking into on the front end to mimic admin_notices?

share|improve this question
up vote 5 down vote accepted

There is no such action in the front end (in a theme) by default. Simply use a custom action like

do_action( 'theme_notices' );

and hook into this one.

share|improve this answer
Awesome. I'll try that. Thank you! – mjleitch Dec 5 '12 at 13:38
Looking into this a bit further... If I'm wanting to make my plugin theme-independent, would it make more sense to set a global variable for the messages rather than using do_action? This way themes could output the messages from any location. If I understand correctly, do_action would be placed in a specific spot in the theme files. Ideally, I'd like to have the notices output during get_header action by default if the theme has no explicit integration with the plugin, but give themes the option to output in a different spot if desired. Does that make sense? – mjleitch Dec 5 '12 at 16:32
There's exactly no such hook anywhere in a theme by default. Using a global would just pollute the namespace. And adding such a custom hook has the same effect (and can be used anywhere and multiple times) plus it doesn't throw around errors when your plugin isn't active and the global isn't set. – kaiser Dec 5 '12 at 16:49
Understood. Thanks. – mjleitch Dec 6 '12 at 0: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.