[英]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.