Forum Moderators: martinibuster

Message Too Old, No Replies

How to block adsense on specific pages?

         

Isa_Al

9:05 pm on Aug 19, 2017 (gmt 0)

5+ Year Member



Hello

I was searching for the past 15 minutes for this but I couldn't find an answer. I want to block Adsense on specific pages on my site but I am wondering how can I do that? I am using WordPress and my theme doesn't allow me to do so. Any idea?

IanCP

12:29 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm trying to understand your question correctly.
I want to block Adsense on specific pages on my site but I am wondering how can I do that?

Simple.

Don't put AdSense code on those specific pages.

Am I missing something?

not2easy

12:54 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It sounds like the code has been integrated either via plugin or widget which would add it to every page (or sidebar or footer) by default. If there's a chance you might not want AdSense on every post or page, it should not be "on" by default. Check to see if your theme has more than one template available such as a full width (no sidebar) template and use that template.

It may not be possible to disable AdSense on any posts or pages, but it depends on how you have set it up on your site. Is the script in the <head>?

keyplyr

1:28 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Or you could robot-out the page(s.)

If you do not have a robots.txt file, just create a txt file containing this:

Disallow: /example1.html
Disallow: /example2.html
Disallow: /example3.html


Change the example to the page file names of the pages you do not want Adsense to display. Then upload via FTP to your hosting account.

It may take up to a week for the Ads to disappear on these pages.

The collateral damage is these pages will be dropped from the Search Engine Results Pages (SERP.)

Isa_Al

1:37 am on Aug 20, 2017 (gmt 0)

5+ Year Member



@IanCP as I mentioned, my theme doesn't allow me to choose which pages I want the header code to appear. I can choose the widgets to disappear from some pages but the header code is installed on all the pages and that's my issue.

@not2easy Yes, my theme,Jarida theme, has just one field to write the header code and doesn't give me any control over which pages I want to place the code in. It's just installed on every single page. I was wondering if Adsense has an option to block the ads from my Adsense account instead of my site.

trebuchet

3:32 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can't disable ad-serving on single pages through the Adsense control panel. You have to do it at your end.

WP plugins/themes with Adsense integration generally give you little control over where ads go. Try editing an individual page/post and look down the right-hand sidebar for a 'Disable Ads' or 'Remove Ads' check box. That's my only suggestion.

not2easy

4:14 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



As trebuchet says, you cannot choose or disable ads per page in the AdSense interface. There are several plugins that claim to help you manage your AdSense. I don't use them and can't recommend any, but some kind of Ad management plugin may allow you to insert ads where you want them to be. Check them out at the Wordpress Plugins area. Search, research and you may find your answer.

MayankParmar

6:28 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



I had the same doubt. So the solution is to just stop using theme to insert ads. Install "Ad-Inserter" plugin and it lets you block ads on specifc post, just put the post ID and that's it. Ad-inserter is a powerful plugin for AdSense.

glitterball

8:04 am on Aug 20, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Off the top of my head, you could achieve it by creating a child theme with a custom footer.

Remove the following line from every adsense unit on your site:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Then, for example, if the ID of the page where you do not want adsense to appear is 15, you would place the following code in your child theme's footer.php:

<?php
$currentpageid = get_the_ID();
If ($currentpageid != 15) {
echo "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>";
}
?>


As long as you have removed the pagead2.googlesyndication.com/pagead/js/adsbygoogle.js from each ad unit, then ads can only appear on pages that have it in the footer.

That's off the top of my head, so there may be bugs/issues!