Where to put code samples

On this Knowledge Base website, you'll see lots of code samples that allow you to modify GravityView functionality. 

There are two ways of adding code to your website:

  1. Via a plugin
  2. Via the functions.php file of your currently active theme

Adding code to your website with the help of a WordPress plugin

If you're not comfortable adding code to your theme's functions.php, then don't do it. If something goes wrong, you can break your website. It's safer to do it with the help of a plugin.

We recommend that you install the following plugin on your WordPress website: Code Snippets.

After the plugin has been installed, you can add a new code snippet:

Adding code to your website by using the theme editor

You can edit your theme's functions.php file by:

  1. Hovering over the Appearance menu
  2. Clicking the "Theme Editor" link in the flyout menu that appears
  3. Clicking on the link named Theme Functions (functions.php)
  4. Modifying the code in the editor
  5. Click the "Update file" button

We do encourage you to learn how to add code yourself, but learning code always (yes, always!) eventually leads to breaking a site. Just know that going in, and you'll be fine :-)

Important tips when adding code:

  1. The code should go after the <?php at the start of the file
  2. The code should go before ?> at the end of the file (if it exists)
  3. Do not nest <?php tags. If you copy/paste code, don't have duplicate opening <?php tags like this:
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.