You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何隐藏WordPress顶部管理栏的「Edit with Elementor」按钮?

隐藏WordPress管理栏中的「Edit with Elementor」按钮

你的代码无法生效,大概率是优先级不足或者节点名称匹配错误,可以试试以下几种解决方案:

方案1:修正PHP函数(推荐)

调整钩子优先级,并覆盖Elementor可能使用的两种节点名称,确保在Elementor添加节点后再移除:

function hide_elementor_edit_link_from_admin_bar($wp_admin_bar) {
    // 移除两种常见的Elementor管理栏节点
    $wp_admin_bar->remove_node('edit-with-elementor');
    $wp_admin_bar->remove_node('elementor');
}
// 把优先级设为1000,确保晚于Elementor的节点添加动作
add_action('admin_bar_menu', 'hide_elementor_edit_link_from_admin_bar', 1000);

如果需要仅对非管理员用户隐藏,可以添加权限判断:

function hide_elementor_edit_link_from_admin_bar($wp_admin_bar) {
    // 仅非管理员用户隐藏该按钮
    if (!current_user_can('manage_options')) {
        $wp_admin_bar->remove_node('edit-with-elementor');
        $wp_admin_bar->remove_node('elementor');
    }
}
add_action('admin_bar_menu', 'hide_elementor_edit_link_from_admin_bar', 1000);

方案2:用CSS快速隐藏

如果不想修改PHP代码,直接通过CSS隐藏按钮,将以下代码添加到主题自定义CSS面板或子主题的style.css文件中:

/* 隐藏Elementor编辑按钮 */
#wp-admin-bar-edit-with-elementor,
#wp-admin-bar-elementor {
    display: none !important;
}

内容的提问来源于stack exchange,提问作者DvB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 18:13:13