How to Customize WooCommerce Account Menu in WordPress

In this tutorial, we’ll guide you through the process customizing the WooCommerce user account menu in WordPress. We’ll demonstrate changes such as removing the ‘Downloads’ tab (‘downloads’) and ‘Addresses’ tab (‘edit-address’) using a child theme. Additionally, we’ll provide an alternative method for those who prefer a non-code approach.

Before proceeding with any customizations in WordPress, it’s essential to set up a child theme. A child theme acts as a safe and efficient way to make modifications without affecting the parent theme. If you haven’t set up a child theme yet, follow this tutorial on How to Create a Child Theme for Customization. It will guide you through the process and ensure that your customizations remain intact even after theme updates.

Access Your Child Theme’s Functions File

Begin by navigating to your WordPress child theme directory and locating the functions.php file. This file is where you can add custom code to change various parts of your WordPress site.

Customize the Menu Items

Within the functions.php file, create a new PHP function to customize the account menu items. This function should accept the existing menu items array as a parameter and identify the keys of the menu items you want to change or remove from the account menu. Customize the menu items by using the unset function.

function custom_modify_account_menu_items( $items ) {
	// Identify the keys of the menu items to modify or remove.
	$keys_to_modify = array( 'downloads', 'edit-address' );

	// Customize the menu items.
	foreach ( $keys_to_modify as $key ) {
		unset( $items[ $key ] );
	}

	return $items;
}

// Hook the custom function to the WooCommerce account menu items filter.
add_filter( 'woocommerce_account_menu_items', 'custom_modify_account_menu_items' );
Code language: PHP (php)

Explanation:

The function custom_modify_account_menu_items dynamically removes specific menu items (‘Downloads’ and ‘Addresses’) from the WooCommerce account menu. The unset function is used to unset the items based on their keys in the menu array.

Alternative Step: Non-Code Approach

For a non-code solution, navigate to WooCommerce > Settings > Advanced. In the Account endpoints section, remove the entry for ‘Downloads‘ and leave it blank. The ‘Downloads’ menu will no longer be visible.

That’s it! This comprehensive guide provides options to optimize and customize the WooCommerce account menu in WordPress. Whether you choose the code-based method using a child theme or the non-code alternative through WooCommerce settings, you can tailor the menu to your preferences.

Leave your feedback and help us improve ๐Ÿถ

We hope you found this article helpful! If you have any questions, feedback, or spot any errors, please let us know in the comments. Your input is valuable and helps us improve. If you liked this article, please consider sharing it with others. And if you really enjoyed it, you can show your support by buying us a cup of coffee โ˜•๏ธ or donating via PayPal ๐Ÿ’ฐ.

More free knowledge, because why not?

Your thoughts matter, leave a reply ๐Ÿ’ฌ

Your email address will not be published. Required fields are marked *