Adding a Contact Form 7 form into a PHP template in WordPress

By 15th October 2014Blog

Sometimes you may want to add a contact form 7 form into a template directly. While normal use is via a shortcode eg,

[contact-form-7 404 "Not Found"]

you can’t use this directly inside a PHP page template.

Instead, you need to wrap this inside the WordPress do_shortcode function, in order to enable it to parse correctly. Wrapping your form up like this will render it correctly in the page using this template:

<?php echo do_shortcode( '[contact-form-7 id="200" title="My Contact Form"]' ); ?>

And voila, you have a CF7 form embedded from inside a PHP page template.



I'm a Wordpress web developer and website designer based in Cheshire, UK. I specialise in Wordpress, Responsive design and website conversion. | Twitter | Linkedin

Leave a Reply