[英]Insert shortcode in functions.php
我在Functions.php中有此代码
add_action( 'woocommerce_single_product_summary', 'bbbbloomer_custom_action', 30 ); function bbbbloomer_custom_action() { echo '<div style="float:left"><a class="btnproduct third datlichthuao" href="#openModal1">Đặt lịch thử áo</a><a class="btnproduct third goilaichotoi" href="#openModal2" >Gọi lại cho tôi</a><a class="btnproduct third chatvoituvan" href="https://www.facebook.com/Marymy.HauteCouture/?ref=br_rs" target="_black">Chat với Tư Vấn</a><a class="btnproduct third tuvan" href="callto:0995999986">Gọi tư vấn</a></div> <div id="openModal1" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> [contact-form-7 id="74" title="Contact Form - Basic"] </div> </div> <div id="openModal2" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> [contact-form-7 id="74" title="Contact Form - Basic"] </div> </div> <div style="clear:both"></div>'; }
但是单击模式时,不会加载短代码“ [contact-form-7 id =“ 74” title =“ Contact Form-Basic”]“,它只是这样的文本( https://i.imgur.com/QbMcnv4。 jpg )。 那么如何显示此短代码中的内容?
您可以尝试使用这种格式
add_action( 'woocommerce_single_product_summary', 'bbloomer_custom_action', 30 ); function bbloomer_custom_action() { ?> <div style="float:left"> <a class="btnproduct third datlichthuao" href="#openModal1">Đặt lịch thử áo</a> <a class="btnproduct third goilaichotoi" href="#openModal2" >Gọi lại cho tôi</a> <a class="btnproduct third chatvoituvan" href="https://www.facebook.com/Marymy.HauteCouture/?ref=br_rs" target="_black">Chat với Tư Vấn</a> <a class="btnproduct third tuvan" href="callto:0995999986">Gọi tư vấn</a> </div> <div id="openModal1" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> <?php echo do_shortcode('[contact-form-7 id="74" title="Contact Form - Basic"]'); ?> </div> </div> <div id="openModal2" class="modalDialog"> <div> <a href="#close" title="Close" class="close">X</a> <?php echo do_shortcode('[contact-form-7 id="74" title="Contact Form - Basic"]'); ?> </div> </div> <div style="clear:both"></div> <?php }
在functions.php
文件中,wordpress挂钩不会自动应用。 您需要做的是,使用do_shortcode
函数并回显返回的html内容。 喜欢
echo do_shortcode('[your_shortcode]');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.