在functions.php

时间:2018-10-28 06:28:11

标签: javascript 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)。那么如何显示此短代码中的内容??

2 个答案:

答案 0 :(得分:0)

您可以尝试使用这种格式

 
    
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
    
    }

答案 1 :(得分:0)

内部functions.php文件的wordpress挂钩不会自动应用。您需要做的是使用do_shortcode函数并回显返回的html内容。像

echo do_shortcode('[your_shortcode]');