How do I add icons on the woocommerce tabs in the my account page?

Picture of Amitpal Singh
Amitpal Singh
October 25, 2021

To add custom HTML to the tab title you can create an array from your icons and change nvaigation.php in the woocommerce template folder like below:

$icons = [
    'dashboard' => '<i class="icon-dashboard"></i>',
    'orders' => '<i class="icon-orders"></i>',
    'edit-account' => '<i class="icon-edit-account"></i>',
    'customer-logout' => '<i class="icon-customer-logout"></i>',
    'downloads' => '<i class="icon-downloads"></i>',
    'edit-address' => '<i class="icon-edit-address"></i>'
]; 

and in the foreach of rendering tabs echo with $endpoint like below:

<?php foreach ( wc_get_account_menu_items() as $endpoint => $label ) : ?>
  <a class="<?php echo wc_get_account_menu_item_classes( $endpoint ); ?>" href="<?php echo esc_url( wc_get_account_endpoint_url( $endpoint ) ); ?>">
    <?php echo $icons[$endpoint] ?>
    <?php echo esc_html( $label ); ?>
  </a>
<?php endforeach; ?> 
with this method, you can add any content to your tabs

it seems like you will modify the WooCommerce template directly in core…
woocommerce/templates/myaccount/navigation.php

When you have to modify a WC template, the correct way to do it is to duplicate the template’s path relative to the woocommerce/templates folder into your theme/plugin’s woocommerce folder.

In child theme
For example in our case, you’d have to paste the template into:
child-theme/woocommerce/myaccount/navigation.php.

Share this post:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.