Customizing URLs

By default, GravityView uses yoursite.com/view/entry/123/ as the URL structure.

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 (Added in Version 1.4) (No longer working)

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 structure, you will likely need to save your Permalinks settings in the Dashboard, under Settings > Permalinks. This should fix the 404 errors.