Customizing URLs

This is an advanced customization. Only continue if you are a developer.

By default, GravityView uses example.com/view/entry/123/ as the URL structure, where 123 is the ID of the entry.

The parts of the URL can be modified:

  • Change /view/ by using the gravityview_slug filter
  • Change /entry/ by using the gravityview_directory_endpoint filter
  • Change /123/ by using the gravityview_entry_slug filter

Let's say you're using GravityView to show health care providers serving your hospital. You want to change /view/entry/123/ to /providers/ref/123/ to improve the URL structure of the site and help your site's SEO value.

Change the base slug for GravityView

Change /view/ to /providers/

add_filter('gravityview_slug', 'change_the_gravityview_slug');    
/**   
 * Change the /view/ URL piece to /providers/  
 * @param  string $slug Previous slug, default: "view"   
 * @return string           Change the new endpoint to "providers"   
 */  
function change_the_gravityview_slug( $slug ) {
      return 'providers';  
}

Changing the entry endpoint

Change /entry/ to /ref/

add_filter('gravityview_directory_endpoint', 'change_the_gravityview_directory_endpoint');    
/**   
 * Change the /entry/ URL piece to /ref/  
 * @param  string $endpoint Previous endpoint, default: "entry"  
 * @return string           Change the new endpoint to "name"  
 */  
function change_the_gravityview_directory_endpoint( $endpoint ) {      
    return 'ref';  
}

There are some values that cannot be used

Certain values are reserved for WordPress. These values aren't allowed:

error, m, p, post_parent, subpost, subpost_id, attachment, attachment_id, name, static, pagename, page_id, second, minute, hour, day, monthnum, year, w, category_name, tag, cat, tag_id, author, author_name, feed, tb, paged, comments_popup, meta_key, meta_value, preview, s, sentence, fields, menu_order

Other values may also not work because of plugin conflicts. If you get errors, try using another value.

After making changes

If you get 404 errors

After making changes to the URL strcuture, you will likely need to save your Permalinks settings in the Dashboard, under Settings > Permalinks. This should fix the 404 errors.

Advanced usage: Use entry values in the URL

Using entry values as the URL slugs is not supported by GravityView support, but it is available for developers to take advantage of. If you have multiple Views that connect to different forms, it's easy to have conflicts between the field values. When using entry values, you must always verify the form ID and/or the View ID when you are changing URLs based on entry values to avoid collisions.

Changing URLs by View

Changing URLs to use entry values, while checking the form ID

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