---
title: "Using [gvlogic] and [gvlogic2] to create &#8220;AND&#8221; logic"
date: 2026-04-23
author: "GravityKit"
link: "https://www.gravitykit.com/docs/gravityview/shortcodes/using-gvlogic-and-gvlogic2/"
---

**There’s a better way:** GravityView has added the ability to use AND or OR logic inside `[gvlogic]` with no extra steps. Use `&&` for AND, use `||` for OR. [Read the  docs to learn how](https://www.gravitykit.com/docs/gravityview/shortcodes/gvlogic-shortcode/#and-or-examples).

### Showing or Hiding Content Based on Two Conditions

The `[gvlogic]` shortcode allows passing multiple conditions by using `&&` for AND, and using `||` for OR. [See how in the  docs](https://www.gravitykit.com/docs/gravityview/shortcodes/gvlogic-shortcode/#and-or-examples).

Sometimes, though, you want to provide nested logic that goes further. 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]
```

```
[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||Cambridge"]
  Your city is either Boston OR Cambridge. You pahk your cah in Hahvad Yahd.
  [gvlogic2 if="{Address (ZIP / Postal Code):8.5}" is="02108"]
    More specifically, you live in the Beacon Hill neighborhood!
  [/gvlogic2]
[/gvlogic]
```

```
[gvlogic if="{Address (City):8.3}" is="Boston||Cambridge"]
  Your city is either Boston OR Cambridge. You pahk your cah in Hahvad Yahd.
  [gvlogic2 if="{Address (ZIP / Postal Code):8.5}" is="02108"]
    More specifically, you live in the Beacon Hill neighborhood!
  [/gvlogic2]
[/gvlogic]
```

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