How to override GravityView templates

How to use your own template files

  • In your theme, create a /gravityview/ directory
  • Find the template file you want to modify. They're located in the []/wp-content/plugins/gravityview/templates/ directory.
  • Copy the file to your theme's /gravityview/ directory
    • If you want to override a file in a sub-directory (like a file in /fields/), make sure to create the sub-directory in your theme as well.
  • 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 list-header.php

  • From the GravityView directory: []/wp-content/plugins/gravityview/templates/list-header.php
  • To your theme's gravityview directory: []/wp-content/themes/[yourtheme]/gravityview/list-header.php

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: []/wp-content/plugins/gravityview/templates/fields/list.php
  • Paste to the /gravityview/fields/ sub-directory in your theme: []/wp-content/themes/[yourtheme]/gravityview/fields/list.php

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).

  • view-[View ID]-table-footer.php
  • form-[Form ID]-table-footer.php
  • page-[ID of post or page where view is embedded]-table-footer.php
  • table-footer.php

For example, if you wanted to override the layout for the single entry view using the Table layout, you would use table-single.php.

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 []/wp-content/themes/[yourtheme]/gravityview/view-46-table-single.php.

The same applies for widgets (using widget IDs) and fields (see "overriding field display" above). Want a different layout for your List fields? view-46-single.php

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 post.php or page.php file in your template directory, rename it single-gravityview.php and start modifying!

Learn more about WordPress template hierarchy.