Using [gvlogic] and [gvlogic2] to create "AND" logic

Showing or Hiding Content Based on Two Conditions

By default, the [gvlogic] shortcode accepts one parameter. But what if you want to check two conditions at once?

You can do that by adding a second shortcode, [gvlogic2 and nesting it within the [gvlogic] shortcode. Here's how:

Create Your Conditional Statement

Now we can nest [gvlogic2] inside [gvlogic] to create an AND statement. The basic structure will look like this:

[gvlogic...]
[gvlogic2]...[/gvlogic2]
[/gvlogic]

Examples

Here we use [gvlogic] and [gvlogic2]to display a message if both conditions are met:

[gvlogic if="{Address (City):8.3}" is="Boston"]
  You pahk your cah in Hahvad Yahd
  [gvlogic2 if="{Address (ZIP / Postal Code):8.5}" is="02108"]
    and you live in the Beacon Hill neighborhood.
  [/gvlogic2]
[/gvlogic]

GravityView 2.5 added the [gvlogic2] into the plugin, without the need for extra code. If you're using an older version of the plugin, upgrade now!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.