Overriding GravityView templates

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.

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 [yoursite.com]/wp-content/plugins/gravityview/templates/ directory.
  • Copy the file and its folder structure to your theme's /gravityview/ directory.
  • That file will now be used instead of the GravityView file!

The same applies to DIY layouts. The difference is that the reference DIY layout file is stored on [yoursite.com]/wp-content/plugins/gravityview-diy/templates/ directory.

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 it doesn't get overwritten when GravityView is updated.

First, create a folder 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: [yoursite.com]/wp-content/plugins/gravityview/templates/views/list/list-header.php
  • To your theme's gravityview directory: [yoursite.com]/wp-content/themes/[yourtheme]/gravityview/views/list/list-header.php *

*Notice that we are not using the /templates/ folder inside your theme.

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

*Notice that we are not using the /templates/ folder inside your theme.

Template File Hierarchy

GravityView has the ability to override templates based on the View ID, the connected Gravity Forms Form ID, and 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 [yoursite.com]/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

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us