Php 如何在模板中调用WordPress短代码?

Php 如何在模板中调用WordPress短代码?,php,css,wordpress,plugins,Php,Css,Wordpress,Plugins,这里有一个插件 要激活表单,您只需将[CONTACT-US-form]放在页面中 我的页面正在调用页面模板。 是否可以在PHP模板中添加[CONTACT-US-FORM]短代码 我试过了,但没用 <?php /* Template Name: [contact us] */ get_header(); ?> [CONTACT-US-FORM] <?php get_footer(); ?> WordPress页面的工作正常,但不是我想要的方法 [CONTACT-US-F

这里有一个插件

要激活表单,您只需将
[CONTACT-US-form]
放在页面中

我的页面正在调用页面模板。 是否可以在PHP模板中添加[CONTACT-US-FORM]短代码

我试过了,但没用

<?php
/*
Template Name: [contact us]

*/
get_header(); ?>
[CONTACT-US-FORM]
<?php get_footer(); ?>
WordPress页面的工作正常,但不是我想要的方法

[CONTACT-US-FORM]
PHP联系我们模板我想试试这样的东西,但没用

<?php
/*
Template Name: [contact us]

*/
get_header(); ?>
[CONTACT-US-FORM]
<?php get_footer(); ?>

[联络我们表格]
在模板中使用此选项

查看此处了解更多信息:

尝试以下方法:

<?php 
/*
Template Name: [contact us]

*/
get_header();
echo do_shortcode('[CONTACT-US-FORM]'); 
?>

确保在文本小部件中启用短代码的使用

// To enable the use, add this in your *functions.php* file:
add_filter( 'widget_text', 'do_shortcode' );

// and then you can use it in any PHP file:  
<?php echo do_shortcode('[YOUR-SHORTCODE-NAME/TAG]'); ?>
//要启用该用法,请将其添加到*functions.php*文件中:
添加_过滤器('widget_text','do_shortcode');
//然后您可以在任何PHP文件中使用它:
查看更多信息。

谢谢已完成