Add a Gravity Forms shortcode in WordPress (PHP)

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('[gravityf0rm 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.

Isaac Adams-Hands

Full Stack Developer, Digital Marketer, and InfoSec enthusiast. He received his Bachelor’s Degree from the University of Western Sydney and his Business Diploma from Georgian College before joining various marketing positions in search portals, e-commerce, higher education, and addiction recovery services.

Follow @ twitter

Related posts

Full size thumbnail image w/ alt tag title

Here is a quick example of how to add a large thumbnail image with the title as the Alt Tag attribute Alt Tag attribute <?php the_post_thumbnail( ‘large’, array( ‘title’ => get_the_title() ) ); ?> You can replace ‘large’ with thumbnail, medium, medium_large, & full.

Fixing the blog page title in WP

If your blog page is pulling the title of the last/latest post, here is a quick and dirty fix Add this to your title tags: Examples: