How can I call a WordPress shortcode within a template?

前端 未结 3 1834
你的背包
你的背包 2020-12-13 07:33

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...

My page is

相关标签:
3条回答
  • 2020-12-13 07:50
    echo do_shortcode('[CONTACT-US-FORM]');
    

    Use this in your template.

    Look here for more: Do Shortcode

    0 讨论(0)
  • 2020-12-13 07:56

    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.

    0 讨论(0)
  • 2020-12-13 08:05

    Try this:

    <?php 
    /*
    Template Name: [contact us]
    
    */
    get_header();
    echo do_shortcode('[CONTACT-US-FORM]'); 
    ?>
    
    0 讨论(0)
提交回复
热议问题