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

无需插件:寻找WoodMart主题WooCommerce中Wishlist和Logout的HTML位置

解决WoodMart+WooCommerce无插件翻译Wishlist/Logout的方法

方法1:通过WordPress过滤钩子自定义文本

直接在子主题的functions.php文件中添加以下代码,替换为你需要的中文内容:

// 替换"My Account"菜单中的Logout文本
add_filter('woocommerce_account_logout_text', 'custom_logout_text');
function custom_logout_text() {
    return '退出登录';
}

// 替换WoodMart主题的Wishlist标题文本
add_filter('woodmart_wishlist_title', 'custom_wishlist_text');
function custom_wishlist_text() {
    return '我的心愿单';
}

// 通用文本过滤,覆盖全站出现的Wishlist/Logout
add_filter('gettext', 'custom_translate_target_text', 20, 3);
function custom_translate_target_text($translated_text, $text, $domain) {
    switch ($text) {
        case 'Wishlist':
            $translated_text = '我的心愿单';
            break;
        case 'Logout':
            $translated_text = '退出登录';
            break;
    }
    return $translated_text;
}

注意:务必使用子主题的functions.php文件,防止主题更新后代码丢失。

方法2:修改主题语言文件

  1. 找到WoodMart主题的语言文件:wp-content/themes/woodmart/languages/woodmart.po
  2. 用Poedit工具打开该文件,搜索"Wishlist"和"Logout",将对应条目翻译为中文
  3. 保存生成.mo文件,建议将修改后的.po和.mo文件复制到子主题的languages目录下,避免主题更新覆盖

方法3:直接在主题可视化设置中修改

  1. 后台进入WoodMart > Header Builder,找到账户菜单模块,编辑对应菜单项目,直接修改"Logout"的显示文本
  2. 进入WoodMart > Wishlist设置面板,检查是否有直接修改Wishlist标题的选项

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 19:33:22