使用挂钩将链接添加到WooComceer
我从@loictheaztec中找到了此代码,可添加,允许您在Woocomceers中的“我的帐户-Dashboard”选项卡中添加一些额外的文本。
我正在尝试添加一个超级链接,但是我的php知识和语法令人震惊,显然我无法使用标准a href html来执行此操作:语法错误:意外的标识符“ https” “,期望”)”
关于如何添加URL的任何帮助,将不胜感激。谢谢。
代码 :
add_action( 'woocommerce_account_content', 'action_woocommerce_account_content' );
function action_woocommerce_account_content( ) {
global $current_user; // The WP_User Object
echo '<p>' . __("<a href="https://google.com"> Request Wholesale account </a>", "woocommerce") . '</p>';
};
I found this code from @LoicTheAztec that adds allows you to add some extra text to the My Account - Dashboard tab in WooComerce.
I am trying to add a hyper link to it however my php knowledge and syntax is appalling and I clearly can't use the standard a href html to do this as this throws an error : syntax error, the unexpected identifier "https", expecting ")"
Any help on how I could add a URL to this would be very much appreciated. Thank you.
Code :
add_action( 'woocommerce_account_content', 'action_woocommerce_account_content' );
function action_woocommerce_account_content( ) {
global $current_user; // The WP_User Object
echo '<p>' . __("<a href="https://google.com"> Request Wholesale account </a>", "woocommerce") . '</p>';
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用的是两次取消彼此的双引号。更简单的方法。另外,您需要将翻译功能与HTML分开。
You are using double quotes twice which cancel each others. simpler way to do it. also you need to separate the translation function from the html.
总是 secave/secure Output 用于使用类似
ESC_HTML _____html ___ 。
Always escape/secure output for security using like
esc_html__
.在马丁的帮助下解决了这个问题。也感谢所有其他建议。
我最终这样做的方式是使用建议的仪表板钩子和单引号回声。
Solved this with Martin's help. Thanks for all the other suggestions too.
The way I ended up doing it was to use the Dashboard hook as suggested and the single quote echo.