Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide the "Post Published. View Post" admin notice in WordPress

Does anyone know how to hide the Post Published message that appears once a post has been published on a WordPress site in the admin.

I have seen this example to hide the Update Available message to all but the admin, but I am not sure what needs to be added to remove the save message:

function hide_update_notice_to_all_but_admin_users() 
{
    if (!current_user_can('update_core')) {
        remove_action( 'admin_notices', 'update_nag', 3 );
    }
}
add_action( 'admin_head', 'hide_update_notice_to_all_but_admin_users', 1 );

I need to remove the message on both regular posts and on custom post types. As far as I can tell, it should be just a case of replacing 'update_nag' but I am unsure of what to replace it with.

Thanks

like image 465
damienoneill2001 Avatar asked Sep 11 '14 15:09

damienoneill2001


Video Answer


1 Answers

This should remove the "Post Published" message.

add_filter( 'post_updated_messages', 'post_published' );

function post_published( $messages )
{
    unset($messages[post][6]);
    return $messages;
}

The above is based on this answer, modified to only remove the "Post Published" message.

like image 96
Howli Avatar answered Sep 30 '22 23:09

Howli