Rename My account tabbed menu items in Woocommerce

蹲街弑〆低调 提交于 2019-12-11 08:47:50

问题


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

Any help is appreciated.


回答1:


Try the following instead (Works in Woocommerce since version 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;
}

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



来源:https://stackoverflow.com/questions/51799919/rename-my-account-tabbed-menu-items-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!