Learn in this tutorial how to insert a custom link in WooCommerce “my account” page with a simple code snippet.
Following the tutorial where I explained how to remove some of the fields that appear on WooCommerce my account page, a subscriber suggested me to prepare one where you can add a custom link.
So here I am. 😉
Remember that WooCommerce, by default, creates a my account page with the following sections:
- Dashboard
- Orders
- Downloads
- Addresses
- Account details
- Logout
But thanks to WooCommerce’s woocommerce_account_menu_items
filter you can remove or add new links.
Here’s how to do it:
Snippet to add a custom link to the my WooCommerce account page
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
You use the woocommerce_account_menu_items
filter to introduce a new element called “Custom Link” that points to the ‘custom-link’ URL.
You also set in which position you want it to be displayed. In this case, it will be displayed as the fifth element, but you can modify it to your liking.
Conclusion
As you can see, with a few lines of code you can insert a custom link on WooCommerce my account page.
If you have any question, please leave it in the comments. And if you want to give me a suggestion for future snippets, please send it through the contact form.
Benefits of being a subscriber. 🙂