我如何将短代码放入PHP代码?

时间:2015-11-05 17:50:51

标签: php wordpress

在Wordpress网站上工作。我需要在其中一个php文件中添加一个短代码(替换一个硬编码到头文件php文件中的搜索条形码)。如何在标题php文件中添加短代码?

这是我正在查看的代码:

<?php if ( (is_front_page()) && (of_get_option('g_search_box_id') == 'yes') ) { ?>
    <div class="search-form-wrap hidden-phone" data-motopress-type="static" data-motopress-static-file="static/static-search.php">
        <?php get_template_part("static/static-search"); ?>
    </div>
<?php } ?>

我需要使用不同的短代码搜索表单删除search-form-wrap(对于mls)。

1 个答案:

答案 0 :(得分:0)

从php文件运行短代码。我们使用do_shortcode函数,例如:

// Use shortcodes in form like Landing Page Template.
echo do_shortcode( '[contact-form-7 id="91" title="quote"]' );
相关问题