Using the [gravityview] shortcode
The [gravityview] shortcode embeds a View on a page, a post, a sidebar widget, or inside another View. Its parameters filter, sort, and limit the entries the View shows.
Tutorial video #
This video walks through the most common uses of the [gravityview] shortcode:
Common use cases #
Most uses of the [gravityview] shortcode display a View, filter its entries, or change their order.
Displaying a View
To display a View, give the shortcode the View’s ID:
[gravityview id="24"]The View editor shows this shortcode, with the ID filled in, under Embed Shortcode in the Publish box, and clicking it copies it. When Enable Enhanced Security is on for the View, the shortcode there includes the View’s secret.

Displaying entries that contain a specific value
[gravityview id="24" search_value="Silver Member" search_field="4"]This lists the entries whose field 4 contains “Silver Member.” The search_value parameter sets the value to look for, and search_field limits the search to one form field.
To find a field’s ID, open the form in the Gravity Forms editor and click the field. The ID shows at the top of Field Settings, as in ID: 4.
Sorting entries by a field
[gravityview id="24" sort_field="4" sort_direction="DESC"]This lists the entries by field 4 in descending order: Z to A for text, and highest first for numbers. The field doesn’t have to be one the View shows.
sort_direction takes ASC (ascending), DESC (descending), or RAND (random order). With sort_field and no sort_direction, the entries are sorted in ascending order.
Always include sort_field when you set sort_direction, also for RAND. To sort by the date entries were submitted or by entry ID, use sort_field="date_created" or sort_field="id". For example, sort_field="date_created" sort_direction="DESC" lists the newest entries first.
To let visitors sort a Table View by clicking its column headings, add sort_columns="1".
Limiting entries by date created
[gravityview id="24" start_date="2021-10-01" end_date="2021-10-31"]This lists the entries submitted from October 1 to October 31, 2021, both days included. Write dates as YYYY-MM-DD, or use relative dates:
[gravityview id="24" start_date="-1month" end_date="today"]Advanced use cases #
Filtering a View with a search operator
The search_operator parameter changes how search_value is compared. For example, this lists the entries whose field 4 isn’t “baseball”:
[gravityview id="24" search_field="4" search_value="baseball" search_operator="isnot"]The search_operator parameter accepts is, isnot, <> (the same as isnot), contains, like, starts_with, ends_with, in, not in, >, <, >=, and <=. Any other value is treated as contains. For in and not in, separate the values with commas, such as search_value="Sales, Support". With like, % stands for any text, as in search_value="Sa%". With isnot, the whole value is compared, so an entry holding “Baseball team” is still listed. Use isnot together with search_field: without it, an entry is listed when any of its fields differs from the value, which is nearly every entry.
Operators other than is, isnot, contains, >, and < need GravityView 3.8.0 or newer.
Displaying the total number of approved entries
GravityView’s approval system lets you approve entries before they show in a View. To display the number of approved entries, use the detail parameter (described below) with search_field="is_approved".
[gravityview id="100" detail="total_entries" search_field="is_approved" search_value="1"]To count disapproved entries, use search_value="2", and for unapproved entries, search_value="3". These two counts need the View’s Show only approved entries setting off; with it on, both come out as 0.
Displaying entries created by a specific user
[gravityview id="42602" search_field="created_by" search_operator="is" search_value="8"]This lists the entries created by the user with ID 8. A user’s ID is in the address of their profile page under Users, as in user-edit.php?user_id=8.
Displaying entries created by the logged-in user
[gravityview id="42602" search_field="created_by" search_operator="is" search_value="{user:ID}"]The {user:ID} merge tag shows the ID of the logged-in user. Logged-out visitors see no entries. Showing user details with the {created_by} and {user} merge tags explains the {user} merge tag.
Filtering by a value in the page address
[gravityview id="24" search_field="2" search_value="{get:city}" search_value_empty="none"]The {get} merge tag fills search_value from the page address. On example.com/members/?city=Denver, this lists the entries whose field 2 contains “Denver”.
When the address has no city parameter, {get:city} comes out empty, and search_value_empty="none" makes the View list no entries. Without it, the View lists every entry. To hide the View or show a message of your own when the value is missing, put the shortcode inside a [gvlogic] condition, as The {get} merge tag shows.
Displaying details about a View #
The detail parameter shows a number about a View in place of its entries. Always include the View’s id, also in a Custom Content field of the same View. The GravityView View Details block shows the same details in the block editor.
Displaying the total number of entries in a View
[gravityview id="10" detail="total_entries"]This shows the number of entries in the View across all its pages.
Displaying the page size
To show how many entries the View lists per page, use detail="page_size":
[gravityview id="10" detail="page_size"]This shows the View’s page size, such as 25, also when the View has fewer entries than that.
All shortcode parameters #
These are the main [gravityview] shortcode parameters:
Required:
id: The ID of the View to display.
Security:
secret: The secret GravityView creates for the View when the setting is on. Enable Enhanced Security: the secret attribute for shortcodes explains the setting.
For example, add secret="your-view-secret" to the shortcode after the View ID, with the View’s own secret in place of your-view-secret.
Searching/filtering:
search_value: Shows only the entries that contain the value.search_field: Limitssearch_valueto one form field. The value must be the field ID, unless you’re searching a meta field such ascreated_by.search_value_empty: What to show whensearch_valueis a merge tag that comes out empty, such as{get:customer}on a page address with nocustomerparameter:noneshows no entries, andallshows every entry. Without it, every entry is shown, and administrators see a notice on the WordPress Dashboard that names the page. Requires GravityView 3.8.0 or newer.search_operator: Changes how the value is compared. The default iscontains. Accepted values:is,isnot,<>(the same asisnot),contains,like,starts_with,ends_with,in,not in,>(greater than),<(less than),>=(greater than or equal to), and<=(less than or equal to). Any other value is treated ascontains.start_date: Lists only the entries submitted on or after this date. Write dates asYYYY-MM-DD, or use relative dates.end_date: Lists only the entries submitted on or before this date. Write dates asYYYY-MM-DD, or use relative dates.
Sorting:
sort_field: The field to sort by: a form field ID,idfor the entry ID, ordate_createdfor the date the entry was submitted.sort_direction: How entries are sorted:ASC(ascending),DESC(descending), orRAND(random). Use it together withsort_field.sort_columns:1lets visitors sort a Table View by clicking a column heading.
Other:
detail: Shows a detail about the View, as described above.class: Adds an HTML class to the View’s wrapper.single_title: A custom title for the Single Entry page. Default: the post or page title.back_link_label: A custom label for the link back from the Single Entry page. Default:← Go back.page_size: The number of entries shown at a time. Without it, the View uses the value in its View Settings. Use-1to show all entries.offset: The number of entries to skip. Withoffset="12", the View starts at the 13th entry.
Shortcode limitations #
The shortcode searches one field at a time. To filter by several fields, with AND or OR, use the Advanced Filtering extension.