wondered if anyone knew the most elegant way to insert some sort of warning message each time someone tries to create a new post, i.e. 'please remember what you publish is your own responsibility', that sort of thing.

I'm thinking I'd like to use the error or warning css wordpress uses if it can't find something or there's an error some place. I'd have thought calling it from the functions file would be best so it doesn't get overwritten each time I update but not really sure what to search to find the reference for it, any ideas?

1 Answer 1

function my_admin_notice(){
    global $pagenow;
    if ( $pagenow == 'post-new.php' || $pagenow == 'post.php') {
         echo '<div class="error">
             <p>This notice only appears on the add and edit post & page.</p>
add_action('admin_notices', 'my_admin_notice');


  • 2
    +1 - removing the == 'post.php' will mean the notice is only printed on new posts. This will also show a message for all post types - so you may want to use get_current_screen() to identify which post type is being viewed. Commented Jun 20, 2012 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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