简体   繁体   English

Wordpress / Woocommerce-将简码变成可点击的链接

[英]Wordpress/Woocommerce- Making a Shortcode a Clickable Link

below is php code that another member posted which allows for a shortcode to be inserted in the short description of every woocommerce product page (code goes into the theme's function.php file). 以下是另一位成员发布的php代码,该代码允许在每个woocommerce产品页面的简短描述中插入一个简短代码(该代码进入主题的function.php文件)。 This has worked perfectly for me, but I have one more thing I need to achieve. 这对我来说非常有效,但是我还需要实现一件事。 I assume this is simple but I have primitive knowledge of php: 我认为这很简单,但是我对php有基本了解:

How do I make the inserted shortcode into a clickable link that links to a url of my choosing? 如何将插入的简码变成可点击的链接,该链接可链接到我选择的网址? Below is the code the is currently working and needs a hyperlink: 下面是当前正在工作的代码,需要超链接:

add_action( 'woocommerce_before_add_to_cart_form', 'enfold_customization_extra_product_content', 15 ); function enfold_customization_extra_product_content() {
echo do_shortcode("[wpqr-code]");}

Try: 尝试:

add_action('woocommerce_before_add_to_cart_form','enfold_customization_extra_product_content', 15); 

function enfold_customization_extra_product_content() {
 echo '<a href="https://www.yourlink.com">'. do_shortcode("[wpqr-code]") . '</a>';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM