Home » WordPress » How to add Contact form 7 in to template file ?

How to add Contact form 7 in to template file ?

Using bellow php code you can embed contact form in to any template file

/**
* Contact form shortdode embed in a template file
* form id is 1514
*/
 
<?php
echo apply_shortcodes( '[contact-form-7 id="1514" title="Newsletter Subscribe"]' );
}
?>

Here I have created a contact form for my Newsltter subscribe form. and it is placed after the woocommerce main content 

/**
* Contact form shortdode embed in a template file
* form id is 1514
*/
 
<?php
 
function wpdumi_newsletter_block(){
echo apply_shortcodes( '[contact-form-7 id="1514" title="Newsletter Subscribe"]' );
}
 
add_action('woocommerce_after_main_content', 'wpdumi_newsletter_block', 1);
 
?>

References

Duminda Wijerathna

An all round web designer building websites Over 18 years. Interested in achieving a suitable placement in the field of IT in a growth oriented organization which offers diverse job responsibilities in order to utilize and improve my skills, Knowledge and experience.

Leave a Comment

Your email address will not be published. Required fields are marked *