I need help adding a second custom menu item to the WooCommerce account area menu
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;
}