在 Woocommerce 中重命名我的帐户选项卡式菜单项 [英] Rename My account tabbed menu items in Woocommerce

查看:41
本文介绍了在 Woocommerce 中重命名我的帐户选项卡式菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的是 Wordpress 4.9.8 版并启用了 Woocommerce 插件.我需要在我的帐户页面中将标签名称仪表板"重命名为我的奖励".

I am currently using Wordpress Version 4.9.8 and enabled Woocommerce plugin. I need to rename the tab name "Dashboard" to "My Rewards" in My account pages.

我找到了下面的代码,但它似乎不起作用:

I found the code below, but it doesn't seem to be working:

function wpb_woo_endpoint_title( $title, $id ) {
   if ( is_wc_endpoint_url( 'dashboard' ) && in_the_loop() ) { // add your endpoint urls
     $title = "My Rewards"; // change your entry-title
     return $title;
}
add_filter( 'the_title', 'wpb_woo_endpoint_title', 10, 2 );

感谢任何帮助.

推荐答案

请尝试以下方法(适用于 Woocommerce 2.6 版以来):

add_filter( 'woocommerce_account_menu_items', 'custom_my_account_menu_items', 22, 1 );
function custom_my_account_menu_items( $items ) {
    $items['dashboard'] = __("My Rewards", "woocommerce");
    return $items;
}

此代码位于活动子主题(或活动主题)的 function.php 文件中.经测试有效.

This code goes in function.php file of your active child theme (or active theme). Tested and works.

这篇关于在 Woocommerce 中重命名我的帐户选项卡式菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆