search ]

Display My Account Link in WooCommerce Templates

The following code displays the link to the “My Account” page on WooCommerce sites. If the user is not logged in, the link will show the text “Login / Register”, otherwise it will show “My Account”.

<?php if ( is_user_logged_in() ) { ?>
	<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woothemes'); ?>"><?php _e('My Account','woothemes'); ?></a>
<?php } 
else { ?>
	<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woothemes'); ?>"><?php _e('Login / Register','woothemes'); ?></a>
<?php } ?>

More information about the My Account page in the post Customizing the My Account page in WooCommerce.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo