php - 在 WordPress 中隐藏 "Post Published. View Post"管理员通知

标签 php wordpress wordpress-theming

有谁知道如何在管理员的 WordPress 站点上隐藏帖子发布后出现的帖子发布消息。

我看到这个例子隐藏了除管理员以外的所有人的更新可用消息,但我不确定需要添加什么来删除保存消息:

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 );

我需要删除常规帖子和自定义帖子类型上的消息。据我所知,这应该只是替换 'update_nag' 的情况,但我不确定用什么替换它。

谢谢

最佳答案

这应该会删除“已发布”消息。

add_filter( 'post_updated_messages', 'post_published' );

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

以上是根据this答案,修改为仅删除“发布后”消息。

关于php - 在 WordPress 中隐藏 "Post Published. View Post"管理员通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25791376/

相关文章:

php - 简单的 WordPress 小部件 : resolving MySQL error

caching - 使用 W3TC Minify HTML/XML 返回的空白页面

php - woocommerce - 帐单字段随不同国家/地区而变化

php - 如何在PHP中获取包含组合字符的Unicode字符串的 "rendered length"?

html 表单上的 JavaScript 或 jQuery

php - 图像在 index.blade.php 中工作但不在 show.blade.php 中工作

html - 站点的 CSS 问题

css - 无法在 WordPress 主题中设置自定义 CSS

php - Mysql查询获取总 child 数?

php - 为什么 MySQL INSERT 语句无法正常运行