【问题标题】:Hide the "Post Published. View Post" admin notice in WordPress在 WordPress 中隐藏“发布的帖子。查看帖子”管理员通知
【发布时间】:2014-11-05 15:13:45
【问题描述】:

有谁知道如何在管理员的 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' 的情况,但我不确定用什么替换它。

谢谢

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

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

    add_filter( 'post_updated_messages', 'post_published' );
    
    function post_published( $messages )
    {
        unset($messages[post][6]);
        return $messages;
    }
    

    以上是根据this的回答,修改为只去掉“Post Published”消息。

    【讨论】:

    • 建议在数组键中引用字符串 unset($messages['post'][6]);隐式转换有时可能会失败。
    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 2011-03-17
    • 2018-07-26
    • 1970-01-01
    • 2011-10-22
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    相关资源
    最近更新 更多