Share this post:

CSS Code

The CSS code below can be pasted into the Customizer (or your preferred location for global CSS). It will hide the badge everywhere on the website, including on the form page itself. If you want to have the badge appear on contact form pages, but not elsewhere check out the code below. Thanks to Travis for leaving this tip on in the YouTube channel comments!

.grecaptcha-badge {
    display: none;
}

Functions.php Code

Paste the code below at the bottom of your functions.php file. Make sure you don’t paste it inside another function in the file. If you do your site will go down until you fix the error. The code below will make it so the badge only appears on pages with contact forms.

You may need to update the “array” to include the slug for pages that have contact forms on your site. In the example below the page domain.com/contact and the page domain.com/some-other-page-with-form will have the badge visible. All other pages will not have the badge. Thanks to Steven for leaving this tip in the YouTube comments!

Advertisement
add_action('wp_print_scripts', function () {
 //Add pages you want to allow to array
 if ( !is_page( array( 'contact','some-other-page-with-form' ) ) ){
  wp_dequeue_script( 'google-recaptcha' );
  //wp_dequeue_script( 'google-invisible-recaptcha' );
 }
});
Share this post:

Responses

Your email address will not be published. Required fields are marked *

WPLearningLab