donglun4521 2017-04-27 10:59
浏览 203
已采纳

创建我自己的WooCommerce登录页面的自定义链接

How can I link my register / login link to the WooCommerce login / register page? I have done a similar thing with the cart page like this

<li class="head_bot_line"><a href="<?php echo WC()->cart->get_cart_url(); ?>">View Basket</a></li>

Is this the correct way to do it? If so how do I link this link to the login / register page?

<li class="head_bot_line"><a href="">Login / Register</a></li>
  • 写回答

2条回答 默认 最新

  • dqalnwuci494308 2017-04-27 11:15
    关注

    You need to echo the My Account page URL. And WooCOmmerce will decide and will redirect the user.

    <?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 } ?>
    

    Official doc: Display My Account link in a template file

    Hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件