Skip to content

Instantly share code, notes, and snippets.

@robin-scott
Last active November 23, 2018 10:38
Show Gist options
  • Save robin-scott/c8309fdab9fac537f4edc13ad3b7779f to your computer and use it in GitHub Desktop.
Save robin-scott/c8309fdab9fac537f4edc13ad3b7779f to your computer and use it in GitHub Desktop.
Display WooCommerce My Account (or login / register for guests) link in a template file - see https://silicondales.com/tutorials/woocommerce/display-woocommerce-account-page-link-logged-users-login-register-link-not-logged/
// Added by Robin Scott of Silicon Dales here to demonstrate My Account / login links: https://silicondales.com/tutorials/woocommerce/display-woocommerce-account-page-link-logged-users-login-register-link-not-logged/
<?php if ( is_user_logged_in() ) { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account','woocommerce'); ?>"><?php _e('My Account','woocommerce'); ?></a>
<?php }
else { ?>
<a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('Login / Register','woocommerce'); ?>"><?php _e('Login / Register','woocommerce'); ?></a>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment