admin管理员组文章数量:1314496
I copied (and customised) the following code which I found online into my functions.php. It has allowed me to add an extra menu item to my WooCommernce account area menu. I now need to add a second menu item and I am not sure how to do this. Does anyone have any advice?
/*My account menu item*/
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' => 'Tour itineraries' );
// array_slice() is good when you want to add an element between the other ones
$menu_links = array_slice( $menu_links, 0, 2, true )
+ $new
+ array_slice( $menu_links, 2, 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('/tour-itineraries');
}
return $url;
}
本文标签: I need help adding a second custom menu item to the WooCommerce account area menu
版权声明:本文标题:I need help adding a second custom menu item to the WooCommerce account area menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741962177a2407343.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论