[英]How can I call a WordPress shortcode within a template?
There's a plugin for the Contact us form .联系我们表单有一个插件。
To activate the form, all you have to do is to place [CONTACT-US-FORM]
in the page...要激活表单,您只需在页面中放置
[CONTACT-US-FORM]
...
My page is calling a page template.我的页面正在调用页面模板。 Is it possible to add the [CONTACT-US-FORM] shortcode in the PHP template?
是否可以在 PHP 模板中添加 [CONTACT-US-FORM] 短代码?
I tried it and it did not work.我试过了,但没有用。
The WordPress page worked, but not the method I want. WordPress 页面有效,但不是我想要的方法。
[CONTACT-US-FORM]
PHP Contact Us template I want to try something like this, but it did not work. PHP Contact Us 模板我想尝试这样的事情,但没有奏效。
<?php
/*
Template Name: [contact us]
*/
get_header(); ?>
[CONTACT-US-FORM]
<?php get_footer(); ?>
echo do_shortcode('[CONTACT-US-FORM]');
Use this in your template.在您的模板中使用它。
Look here for more: Do Shortcode在这里查看更多信息: 做短代码
Try this:试试这个:
<?php
/*
Template Name: [contact us]
*/
get_header();
echo do_shortcode('[CONTACT-US-FORM]');
?>
Make sure to enable the use of shortcodes in text widgets.确保在文本小部件中启用短代码的使用。
// 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]'); ?>
Check the documentation for more.查看文档了解更多信息。
// Use shortcode in a PHP file (outside the post editor). //在PHP文件中使用短代码(在帖子编辑器之外)。
echo do_shortcode( '' );
// Use shortcodes in form like Landing Page Template. //使用登陆页面模板等形式的短代码。
echo do_shortcode( '[contact-form-7 id="91" title="quote"]' );
//Same Way //同样的方式
echo do_shortcode('[CONTACT-US-FORM]');
Please just go through the reference link [Link] 请点击参考链接[链接]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.