Preventing Views and Entries from being crawled by the Google Crawler/Bot

Sometimes your Views might contain sensitive data; therefore, you might want to prevent them from being indexed by Google and other search engines. To achieve that, you'll need to create a file on your WordPress root directory called  Robots.txt.

Then, write the following instructions inside this text file:

User-agent: *

Disallow: /view/*/entry/*

Disallow: /*/entry/*


Removing access to the View custom post type

Views are registered on WordPress as Custom Post Types, and they are accessible via the /view/ slug on the URL. It's possible to completely remove access to this custom post type by using the filter below:

add_filter( 'gravityview_direct_access', '__return_false' );

When using this filter, only Views embedded using the [gravityview] shortcode will show up/work. 


Preventing Views from being accessible by default

A screenshot from the Settings metabox inside the View Editor showing the Prevent Direct Access option in the Permissions tab.

By using the code snippet below, the "Prevent Direct Access" option will be checked by default on all newly created Views:

add_filter('gravityview/view/settings/defaults', function($default_settings){

$default_settings['embed_only']['value'] = true; //Prevent Direct Access

return $default_settings;

});

Removing the View Custom Post Type from Yoast SEO

SEO plugins such as Yoast will automatically add all Custom Post Types (such as GravityView Views) to your website sitemap that is accessed by Google & other search engines. There's a way to exclude them from the sitemap explicitly.

In Yoast, for instance, this can be done by accessing the "SEO > Search Appearance" menu and then the Content Types tab: 

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