Add a Gravity Forms shortcode in WordPress (PHP)

by

To add a Gravity Form shortcode in the header, page, footer templates… pretty much anywhere in the theme, just add this code in your PHP file:

<?php echo do_shortcode('[gravityform id=1 name=ContactUs title=false description=false]'); ?>

You can also add the embed codes:

Basic
<?php gravity_form( 1, false, false, false, '', false ); ?>

This snippet will display the form with an id of ‘1’; the title and description will not be displayed, the form itself will not display if it is inactive, and it will not use AJAX for form submission.

With Ajax & Tabindex

<?php gravity_form(1, false, false, false, '', true, 12); ?>

This snippet will display the exact same form as above except it will use AJAX for form submission and the starting tabindex will be 12.

Using the Form Title instead of ID

<?php gravity_form('Contact Us', false, false, false, '', false); ?>

This snippet will display the form titled ‘Contact Us’; the title and description will not be displayed, the form itself will not display if it is inactive, and it will not use AJAX for form submission.

Leave a Reply

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


PageLines