简体   繁体   English

更改 Woocommerce 中我的帐户页面上的标题

[英]Changing the titles on My Account pages in Woocommerce

I've seen loads of example of how to re-order / change the navigation and page with the WooCommerce my account dashboard.我已经看到了很多关于如何使用 WooCommerce 我的帐户仪表板重新排序/更改导航和页面的示例。 But i can't for the life of me work out how to change the main titles for each section (My Account, Orders, Downloads, Addresses etc).但我一生都无法弄清楚如何更改每个部分(我的帐户、订单、下载、地址等)的主要标题。

I've searched through the templates but no joy.我已经搜索了模板,但没有任何乐趣。 I've tried using conditional php comments to echo the titles for the correct page.我尝试使用条件 php 注释来回显正确页面的标题。 But it doesn't work because my account section uses endpoints.但它不起作用,因为我的帐户部分使用端点。 I've tried adding a filter, but no joy.我试过添加一个过滤器,但没有任何乐趣。 Anyone got any idea how i change these titles?有人知道我如何更改这些标题吗?

Thanks谢谢

It can be done using the composite filter hook woocommerce_endpoint_{$endpoint}_title .可以使用复合过滤器钩子woocommerce_endpoint_{$endpoint}_title

For example if you need to change the My Account "** Account details**" title you will use (where the endpoint is edit-account ) :例如,如果您需要更改您将使用的“我的帐户”“** 帐户详细信息**”标题(端点为edit-account

add_filter( 'woocommerce_endpoint_edit-account_title', 'change_my_account_edit_account_title', 10, 2 );
function change_my_account_edit_account_title( $title, $endpoint ) {
    $title = __( "Edit your account details", "woocommerce" );

    return $title;
}

Code goes in function.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 function.php 文件中。 Tested and works.测试和工作。

在此处输入图片说明

发现我可以使用 woo_endpoint_title 过滤器。

This worked for me to rename the titles of all my account pages:这对我重命名我所有帐户页面的标题有用:

function wpb_woo_endpoint_title( $title, $id ) {
           
            if ( is_wc_endpoint_url( 'orders' ) && in_the_loop() ) {
                $title = "Deine Buchungen";
            }
            elseif ( is_wc_endpoint_url( 'edit-address' ) && in_the_loop() ) {
                $title = "Deine Rechnungs- & Behandlungsadresse"; 
            }
            elseif ( is_wc_endpoint_url( 'payment-methods' ) && in_the_loop() ) {
                $title = "Deine Bezahlmethoden";  
            }
            elseif ( is_wc_endpoint_url( 'edit-account' ) && in_the_loop() ) {
                $title = "Dein Nutzerkonto"; 
            }
            return $title;
        }
        add_filter( 'the_title', 'wpb_woo_endpoint_title', 10, 2 ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何更改 WooCommerce 我的帐户页面标题? - How to change WooCommerce My Account page titles? 在 WooCommerce 中设置我的帐户自定义项目端点标题 - Set My Account custom items endpoints titles in WooCommerce 在 WooCommerce 中编辑我的帐户订单视图页面 - Editing My account Order view pages in WooCommerce 检测 WooCommerce“我的帐户”页面的仪表板 - Detect dashboard of WooCommerce "my account" pages WooCommerce:在我的帐户页面中为自定义模板分配端点 - WooCommerce: Assigning an endpoint to a custom template in my account pages 如果未登录,将 WooCommerce 页面重定向到我的帐户页面(问题) - Redirect WooCommerce pages to My Account page if not logged in (Issue) 在 Woocommerce 3 中的我的帐户订单查看页面上显示付款说明 - Display payment instructions on my account order view pages in Woocommerce 3 将一些我的帐户自定义字段添加到 Woocommerce 的管理员用户页面 - Adding some my account custom fields to admin user pages in Woocommerce 在 Woocommerce 的我的帐户订单视图页面上添加 sku 以订购商品 - Add the sku to order items on my account order view pages in Woocommerce WooCommerce -Thankyou 和“我的帐户”查看订单页面上的自定义通知 - WooCommerce - Custom notice on Thankyou and "My account" view order pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM