Using the [gravityview] Shortcode

You can embed GravityView in a post or page.

You can embed GravityView Views in posts or pages by using the [gravityview] shortcode.

Shortcode Parameters

  • id - The ID of the View you want to display (required)
  • page_size - Number of entries to show at a time (Defaults to View setting)
  • sort_field - What form field id should be used to sort? (See note)
  • sort_direction - ASC / DESC
  • search_field - Only display entries with this text in the value (See note)
  • search_value - Only display entries with this text in the value
  • start_date - Filter the results by date. This sets a limit on the earliest results shown. In YYYY-MM-DD format. You can now use relative dates.
  • end_date - Filter the results by date. This sets a limit on the latest results shown. In YYYY-MM-DD format. You can now use  relative dates.
  • class - Add a HTML class to the view wrapper
  • offset - This is the start point in the current data set (Count starts with 0)
  • single_title - Define a custom single entry view title (default: post/page title)
  • back_link_label - Define a custom single entry back link label (default: ← Go back)
  • post_id - When using the shortcode in a widget or template, you may want to specify a page where a View is embedded as the base URL for entry links. Default: NULL (added in Version 1.4)
  • detail - Display specific information about a View Read more below (Since Version 1.13)

Note: You can find the field ID by looking at each field's title in the Gravity Forms Form Editor

Examples

This shortcode will display entries for View #123

[gravityview id="123" search_value="example" start_date="2014-06-16" end_date="2014-06-17" /]

Only search for "Example" in the field ID #5 for View #123.

[gravityview id="123" search_field="5" search_value="Example"]

Display the View, but have entries link to the post with ID of 40. Instead of yoursite.com/view/123/entry/5/, the entry would link to yoursite.com/post-40-url/entry/5/.

[gravityview id="123" post_id="40"]

The detail Shortcode Parameter

Since Version 1.13

When the detail parameter is defined when using the [gravityview] shortcode, the shortcode will output information about the current View. It must be used inside a View's Custom Content field to display accurate information.

Possible Values

  • [gravityview detail="total_entries"] The total number of entries that are in the View. If displaying search results, the number of matched entries. (100 in the below example)
  • [gravityview detail="first_entry"] (26 in the below example)
  • [gravityview detail="last_entry"] (50 in the below example)
  • [gravityview detail="page_size"] The number of entries that are visible on a single page. If all entries are displayed, then the value will be the same as total_entries (25 entries were displayed in the below example)

Examples

Example: a View that is showing entries 26-50 of 100 entries.

If you add this to a Custom Content widget:

<p>There are [gravityview detail="total_entries"] entries that match your search.</p>

It will display the following on a View with 100 entries:

<p>There are 100 entries that match your search.</p>