Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.