Created
March 19, 2019 09:20
-
-
Save thegulshankumar/93e8ba9b5cfe12178016bbe01d388951 to your computer and use it in GitHub Desktop.
Disable Adsense Ads From 404 Pages In Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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