Wordpress:将“我的帐户”重命名为会员姓名

时间:2017-12-16 09:30:10

标签: wordpress woocommerce

如何将“我的帐户”重命名为会员姓名exp:“John”(参见下图):

enter image description here

我尝试过更改wp-content / themes / themeName / framework / functions / woo-account.php:

printf( __( '%s', 'wpdance' ),$current_user->user_lastname);

先前:

printf( __( 'My Account', 'wpdance' ));

但仍然无法正常工作。

谢谢。

1 个答案:

答案 0 :(得分:1)

只需转到YOUR_URL / wp-admin / edit.php?post_type = page,您就会看到"我的帐户"那里的页面(由WooCommerce自动创建)。重命名该页面即可。

要显示当前用户的名称而不是"我的帐户",请将此代码添加到functions.php文件中。

function rename_my_account( $title, $id = null ) {
    if ( $title=='My account' and is_user_logged_in()) {
        $current_user=wp_get_current_user();
        return $current_user->display_name;
    }
    return $title;
}
add_filter( 'the_title', 'rename_my_account', 10, 2 );