Welcome to part #8 of Getting Started With GravityView. In this section of the course, you’ll learn how to embed a View on a page or post.
The GravityView Shortcode
The GravityView shortcode allows you to embed Views on your website. The shortcode accepts several parameters, allowing you to:
- Filter entries
- Change the sort direction
- Only display entries created within a certain timeframe
- Display entries created by a specific user
… and more!
Embedding a View on a Page or Post
First, edit your View and copy the embed shortcode (you’ll find it on the right, above the Update button).
Next, create a new page or post, click on the ‘+’ icon and select the Shortcode block.
Now paste the GravityView embed shortcode inside the shortcode block.
If you’re still using the classic editor…
Simply click on the “Add View” button above the text editor.
Select the View you want to embed from the dropdown menu and configure the remaining settings below (optional). When you’re done, click “Insert View”.
You’ll see the embed shortcode is now inserted into the editor.
GravityView also adds two widgets to WordPress. These widgets are different from those added inside a View. These are WordPress widgets that can be used in the sidebar, footer or any other widget area on your website.
The two widgets are the Recent Entries widget and the Search widget
- GravityView Recent Entries Widget
- GravityView Search Widget
GravityView Recent Entries Widget
The Recent Entries widget allows you to display entries recently added to a View.
- Widget title
- The View where you want to display entries from
- The number of recent entries to display
- The link text that users can click on to go to the entry
- Additional content to show below the entry link
Note: if your View is embedded in a post or page, you’ll need to add the page ID to the input box.
GravityView Search Widget
The GravityView search widgets allows you to search for entries from a specific View from anywhere on your site.
- The title of the search widget, displayed above the search input boxes
- The View that you want to search
- If you want users to search entries from an embedded View, you’ll need to add the page ID where the View is embedded
- Show the “clear” button, allowing users to clear a search
- Choose how you want your search bar to operate. You can set searches to match any field or only one field.
- The search input fields
In this lesson, we showed you how to embed a View on a page or post. We also introduced you to GravityView WordPress widgets and how to utilize them on your website.
See you in the next lesson 👋