What I was after

I recently upgraded to reCAPTCHA v3 with my site’s contact form and it annoyingly injected the reCAPTCHA badge on all of my site’s pages rather than just the ones that are actively using reCAPTCHA.

I was looking for a way to only show the badge on my Contact page.

The Result(s)

I came across this video by WordPress Tutorials – WPLearningLab, but their method no longer worked. I used it as a base for my own modified method.

The Important Bits

  1. Go to your WordPress theme’s CSS folder and add a new file with the following CSS (I named my file decaptcha.css):
     
    .grecaptcha-badge { visibility: hidden; }
  2. Edit your theme’s functions.php file and insert this string at the bottom of the file above the final ?> line:
     
    // Remove recaptcha tag from all pages but contact page
        add_action('wp_print_scripts', function () {
        //Add pages you want to allow to array
        if ( !is_page( array( 'contact' ) ) ){
        wp_enqueue_style( 'catcha-style', get_template_directory_uri() . '/css/decaptcha.css' );
        }
        });
  3. You may want to edit two things – 'contact' should be the slug of the page you want the reCAPTCHA badge to appear on and your CSS directory and the name of your “decaptcha” CSS file may be different.

Now the reCAPTCHA badge will only appear on the contact page. Hiding the tag via CSS is the Google-approved approach.