Skip to content

Instantly share code, notes, and snippets.

@thegulshankumar
Created March 19, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegulshankumar/93e8ba9b5cfe12178016bbe01d388951 to your computer and use it in GitHub Desktop.
Save thegulshankumar/93e8ba9b5cfe12178016bbe01d388951 to your computer and use it in GitHub Desktop.
Disable Adsense Ads From 404 Pages In Wordpress
/*
Instructions
Step 1. Remove adsbygoogle.js from all Ad units
Step 2. Paste below snippet in the Theme functions.php or use Code Snippets plugin
*/
function conditional_adsense_display() {
if ( ! is_404( ) ) echo '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';}
add_action('wp_head', 'conditional_adsense_display');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment