In this edition of Feature Highlights, we’re exploring the powerful [gravityview] shortcode. No, it’s not only for embedding Views! The [gravityiew] shortcode allows you to filter entries by specific values, display the total number of entries in a View, and much more.
Shortcodes in WordPress are text strings enclosed in square brackets. They allow you to embed interactive content on your site without writing any code. GravityView adds several new shortcodes to WordPress including the [gravityview] shortcode which we’re going to explore in this post 👇
How to Use the Shortcode
You can find the [gravityview] shortcode on the View Editor page above the “Update” button. Here it’s referred to as the “Embed Shortcode”, but there’s a lot more you can do with it besides simply embedding Views.
The shortcode only has one required parameter: the View ID. All other parameters are optional and can be used if/when you need them!
The [gravityview] shortcode accepts a wide range of parameters. Here are some of the common ones that you can use to filter your Views based on specific field values:
search_value– Only display entries that contain the specified value
search_field– Restrict the search_value to a specific form field. The value must be the field ID, unless you’re searching on a meta field (e.g. “created_by”).
search_operator– Change the type of search to be performed. The default is “contains”. Accepted values include:
start_date– Filter the results by date. This sets a limit on the earliest results shown.
end_date– This sets a limit on the latest results shown.
detail– Display specific information about a View. The detail parameter can be used inside a Custom Content field to display information about the currently-displayed View.
💡 Pro tip: To see a full list of accepted parameters, check out this detailed article on our docs site.
Use Cases for the [gravityview] Shortcode
Reading through a list of different shortcode parameters is all well and good, but sometimes it helps to look at some examples of common use cases.
1. Embedding a View:
2. Filtering a View to display entries that contain a certain value:
[gravityview id="24" search_value="Silver Member" search_field="4"]
3. Limiting entries by date created:
[gravityview id="24" start_date="2021-10-01" end_date="2021-10-31"]
4. Displaying the total number of entries in a View:
[gravityview id="10" detail="total_entries"]
💡 Pro tip: You can use a [gravityview] shortcode with the detail parameter inside a custom content field to display information about the View being displayed.
There are plenty more use cases for the [gravityview] shortcode. To see more examples of things you can do, check out our documentation.
What the [gravityview] Shortcode CAN’T Do
We’ve focused a lot on what the [gravityview] shortcode CAN do (and it can do a lot of things!), but it’s also important for us to mention what it CAN’T do.
While [gravityview] includes some powerful filtering capabilities, there are some limitations. For example, you can’t search for multiple values or specify multiple search fields. You also cannot use AND/OR logic in searches.
However, if you need this functionality, don’t despair, because you can accomplish this with our Advanced Filtering extension.
Get Started With the [gravityview] Shortcode!
In this edition of Feature Highlights, we explored the powerful [gravityview] shortcode. Using the shortcode, you can embed Views, filter entries based on various criteria and display specific details about a particular View.
Join Our Newsletter!📧🙌
✅ Helpful Gravity Forms content straight to your inbox
✅ Be the first to hear about new updates and releases