Blocking adsense ad units for a particular country [closed]

A quick google search gave me this. This plugin seems to have this feature: http://wordpress.org/extend/plugins/ad-injection/faq/ How can I show different ads to people in different countries? If you install the Country Filter plugin (with the IP database) then you can use the following code in the direct ad insertion modes. This will not work in … Read more

Adsense: You have rejected ad requests, which will result in lost revenue [closed]

Do not change your AdSense ad code because of this rejected ad requests issue! This is a system glitch that Google will correct. Google has recognized and added the issue to their “Known Issues” list with the following description: “Some accounts incorrectly notified about rejected ad requests” We recently changed the way our system surfaces … Read more

How to add Adsense code to child theme

You can easily put your Google Adsense code within the <head> element of your WordPress site by using either of these methods in your functions.php file or by creating a plugin for that purpose: /** * Load my Google Adsense code. * * Here, your Google Adsense Code is stored within in your plugins directory, … Read more

Block Adsense on specific page

You can use this function: <?php if(is_page(‘your-page-slug’)): ?> //do nothing on selected pages <?php else: ?> <script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js” /> <script> </script> <?php endif; ?> If you want to disable this on more than one page, just add them like this: <?php if(is_page(‘your-page-slug1’) || is_page(‘your-page-slug2’)): ?> WordPress Developer Resources are very useful (more than codex), … Read more

Inserting AdSense code right after tag

Without using a plugin, the WordPress way would be to use the wp_head action to insert the script and then enqueue the script file: function mytextdomain_adsense() { $output=” <script> </script>”; echo $output; } add_action(‘wp_head’,’mytextdomain_adsense’); function mytextdomain_adense_script() { wp_enqueue_script( ‘my-adsense’, ‘//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js’, array(), ‘1.0.0’, false ); } add_action( ‘wp_enqueue_scripts’, ‘mytextdomain_adense_script’ ); And to add the async attribute … Read more

Adding Google Custom Search to a Public Released Theme

You can improve it, combining Google Search and WordPress Search. using this simple javascript: function displaygoogle(checkbox){ if(checkbox.checked){ document.getElementById(“googlesearchbox”).style.display = ‘block’; document.getElementById(“wordpresssearchbox”).style.display = ‘none’; document.getElementById(“googlesearchinput”).value = document.getElementById(“wordpresssearchinput”).value; } else{ document.getElementById(“googlesearchbox”).style.display = ‘none’; document.getElementById(“wordpresssearchbox”).style.display = ‘block’; document.getElementById(“wordpresssearchinput”).value = document.getElementById(“googlesearchinput”).value; } } see more detail here: http://jaider.net/2011-05-08/how-to-combine-google-wordpress-search/

How to detect Adblock on my website?

My solution is not specific to a certain ad network and is very lightweight. I’ve been running it in production for a few years. AdBlock blocks all URLs containing the word “ads” or “prebid”. So this is what I did: I added a small js file to my webroot with the name prebid-ads.js Update 2021-04-12: you might … Read more