Conditional Content Display in Gravity Forms Templates

I don’t know when the conditional shortcode was added or if it has always existed and I was just unaware . . . but the ability to use a shortcode wrapper to show/not show portions of content in blog posts created via Gravity Forms is all kinds of handy.

As a quick example, the following content would not show if the entry to the form field {What’s up?:1} was empty.

[gravityforms action="conditional" merge_tag="{What's up?:1}" condition="isnot" value=""]
<h2>{What's up?:1} - more words</h2>[/gravityforms]

In the past, if we didn’t have the wrapper and we had no response on the ‘What’s up?’ field we’d be left with the awkward ‘ – more words’ being there.

This is so very nice for optional content where you might want to add additional html structure — like a link to an attachment but *only* if the attachment exists. It solves so very many problems so easily.

You could also display different additional HTML elements based on the response to specific field entries. Like if a ranking on a scale of 1-5 is a 5 show a particular overly happy gif.

[gravityforms action="conditional" merge_tag="{How happy?:1}" condition="is" value="5"]
<img src="https://i.imgur.com/5tCHDqm.jpg" alt="a very happy turtle">
[/gravityforms]

2 thoughts on “Conditional Content Display in Gravity Forms Templates

Comments are closed.