How To Add Menu or Remove Menu Link On Woocommerce "My Account" Page WordPress | Kazukiyan

How To Add Menu or Remove Menu Link On Woocommerce "My Account" Page WordPress KAZUKIYAN

This tutorial is rarely found on the Search Engine that is why we made a quick guide how you can actually customize your MY ACCOUNT Page of your Woocommerce websites such as Remove Menu or Add Menu with Links using only the functions.php file, so it means no plugin involves, it is useful especially when your client wanted you to add a specific menu that is why we have this tutorial for you.


There are other solutions for implementing this functionality, but it is advisable to minimize the use of plugins for your WordPress shop built with WooCommerce. It is a good tactic to leverage the built-in features of WordPress and WooCommerce. By following the correct method of adding a custom menu or removing specific menu links, you can achieve the desired outcome using functions. Please refer to the guide below for detailed instructions, or alternatively, you can watch the accompanying video that we have prepared to assist you in finding a solution for your specific needs.



As you can see on the video it has a quick explanation of how to use the code, so just follow the tutorial video above made by us in our YouTube Channel Kazukiyan Official and then just copy the code we have included here.

How To Remove Menu on My Account?

add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){

unset( $menu_links['edit-address'] ); // Addresses


//unset( $menu_links['dashboard'] ); // Remove Dashboard
//unset( $menu_links['payment-methods'] ); // Remove Payment Methods
//unset( $menu_links['orders'] ); // Remove Orders
//unset( $menu_links['downloads'] ); // Disable Downloads
//unset( $menu_links['edit-account'] ); // Remove Account details tab
//unset( $menu_links['customer-logout'] ); // Remove Logout link

return $menu_links;

}

Just uncomment the code in which you want to remove a specific tab menu on your my-account page.


How To Rename The Menu Tabs for My Account Page?

add_filter ( 'woocommerce_account_menu_items', 'misha_rename_downloads' );

function misha_rename_downloads( $menu_links ){

// $menu_links['TAB ID HERE'] = 'NEW TAB NAME HERE';
$menu_links['downloads'] = 'My Files';

return $menu_links;

}

TAB ID HERE: you just replace that to a constant id menu which is listed below.

  • dashboard
  • payment-methods
  • orders
  • downloads
  • edit-account
  • customer-logout
NEW TAB NAME HERE: This is where your custom tab menu, replace this one with your own tab menu name.

How You Can Rename Tabs Menu in My Account

Add A Custom URLs for Menu in My Account Page



add_filter ( 'woocommerce_account_menu_items', 'misha_one_more_link' );
function misha_one_more_link( $menu_links ){
 
// we will hook "anyuniquetext123" later
$new = array( 'kazukiyantext123' => '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;
 
}

kazukiyantext123: Replace it with your custom link for example blog/, contact/, services/ etc.

Post a Comment

Previous Post Next Post