Overriding GravityView templates
How to use your own template files
- In your theme, create a
- Find the template file you want to modify. They're located in the
- Copy the file and its folder structure to your theme's
- That file will now be used instead of the GravityView file!
Template override example:
You want to modify the
list-header.php file. Instead of editing the GravityView plugin, you should copy the template file to your theme so that it doesn't get overwritten when GravityView is updated.
First, create a file in your theme's directory like so:
Then copy the file you wish to modify, in this case
- From the GravityView directory:
- To your theme's
The same goes for overriding field display
If you want to change how the Gravity Forms List field type is displayed
- Copy from the GravityView directory:
- Paste to the
/gravityview/fields/sub-directory in your theme:
Template File Hierarchy
GravityView has the ability to override templates based on the View ID, the connected Gravity Forms Form ID, the ID of the page that a View is embedded on (if using the shortcode).
page-[ID of post or page where view is embedded]-table-footer.php
For example, if you wanted to override the layout for the single entry view using the Table layout, you would use
If you want to override how it looks for a View with ID
46, you would create a file named
view-46-table-single.php. The final path would be
The same applies for widgets (using widget IDs) and fields (see "overriding field display" above). Want a different layout for your List fields?
Overriding the page template
You can override the page template used to display GravityView Views by creating a
single-gravityview.php template file. This is useful, for example, if you want GravityView Views to be displayed without sidebars, or without a menu bar.
GravityView Views are "Custom Post Types" with a slug of
gravityview. You can override how your theme displays single GravityView Views by creating a
single-gravityview.php template file. Duplicate the
page.php file in your template directory, rename it
single-gravityview.php and start modifying!