Woocommerce 如何在我的帐户中添加子菜单?
我想请求一些帮助Woocommerce 如何在我的帐户中添加子菜单?,woocommerce,Woocommerce,我想请求一些帮助 add_filter ( 'woocommerce_account_menu_items', 'misha_one_more_link' ); function misha_one_more_link( $menu_links ){ // we will hook "anyuniquetext123" later $new = array( 'anyuniquetext123' => 'Gift for you' );
add_filter ( 'woocommerce_account_menu_items', 'misha_one_more_link' );
function misha_one_more_link( $menu_links ){
// we will hook "anyuniquetext123" later
$new = array( 'anyuniquetext123' => 'Gift for you' );
// or in case you need 2 links
// $new = array( 'link1' => 'Link 1', 'link2' => 'Link 2' );
// array_slice() is good when you want to add an element between the other ones
$menu_links = array_slice( $menu_links, 0, 1, true )
+ $new
+ array_slice( $menu_links, 1, NULL, true );
return $menu_links;
}
add_filter( 'woocommerce_get_endpoint_url', 'misha_hook_endpoint', 10, 4 );
function misha_hook_endpoint( $url, $endpoint, $value, $permalink ){
if( $endpoint === 'anyuniquetext123' ) {
// ok, here is the place for your custom URL, it could be external
$url = site_url();
}
return $url;
}
我正在使用此代码在我的WooCommerce帐户页面上添加自定义菜单:
这很有效,但只增加了菜单链接。我想在“给你的礼物”下添加子菜单,例如“给她”或“给他”。我找到的唯一解决方案是覆盖文件
plugins/woocommerce/templates/myaccount/navigation.php,并在里面做任何你想做的事;)