How To Disable Ads On Posts: Google AdSense Plugin For WordPress

Despite mixed reviews, I’m a fan of the official Google AdSense Plugin for WordPress because it’s easy to set up, works beautifully on mobile devices, and seems to generate more revenue than ad units I place myself. Best of all, it’s a huge timesaver—and I’ve spent a lot of time tweaking ad layouts in the past. In this article, I’ll show you how to enable the AdSense Plugin meta box so you can disable ads on single posts.

WordPress AdSense Plugin Meta BoxI recently launched a new section of this website with posts that I don’t want to have ads, but when I went to disable the ads on those specific posts, I noticed something strange: Even though there was a AdSense Plugin meta box with a “Disable ads on this page” checkbox in the WordPress Pages editor, there was no AdSense Plugin meta box in the Posts editor.

I Googled the problem and didn’t find anything but frustrated users, but I figured that if you could disable AdSense for individual pages, the functionality must already be built in. The solution is as simple as changing a single line of code. We’ll enable the AdSense plugin meta box for pages and posts, so you can disable ads on single posts in WordPress. 

How To Disable Ads On Single WordPress Posts With The Google AdSense Plugin

  1. Go to Plugins -> Editor in the WordPress dashboard.
  2. Select Google AdSense in the Select plugin to edit: menu at the top, and click Select.
  3. From the list of files on the right, click to open the file called google-publisher/Admin.php.
  4. Change ‘page’ to array(‘page’, ‘post’) in this section of code, so this:
     public function addPageEditOptions() {
        add_meta_box('googlePublisherPluginMetaBox',
            __('AdSense Plugin', 'google-publisher-plugin'),
            array($this, 'showPageEditOptions'), 'page', 'side', 'low');
      }

    becomes this:

     public function addPageEditOptions() {
        add_meta_box('googlePublisherPluginMetaBox',
            __('AdSense Plugin', 'google-publisher-plugin'),
            array($this, 'showPageEditOptions'), array('page', 'post'), 'side', 'low');
      }

    Edit Google AdSense Plugin WordPress

  5. Click Update File to save your edits.
  6. Return to the WordPress post editor and check the box next to Disable ads on this page.Check Disable Ads On This Page
  7. Update or Publish the post with no ads.

That’s right: We fixed the problem by changing a single line of code!

Wrapping It Up

By this point, you’ve successfully added the AdSense Plugin meta box to the WordPress editor and you can disable ads on the posts you choose. Writing good articles is all about user experience, and users don’t like seeing ads—so when I need to turn them off, it’s a win-win for me and for my readers.

Thanks for reading, and remember to Payette Forward,
David P.

About Author

I'm a former Apple employee and the founder of Payette Forward, and I'm here to help you with your iPhone.

Subscribe
Notify of
9 Comments
Inline Feedbacks
View all comments
Anonymous
6 years ago

i hope it does cause i’m about to try it on my blog post

Anonymous
7 years ago

This doesn’t work

rhea sinha
7 years ago

This worked perfectly. Thanks a lot for the simple precise instructions.

Elisabeth van der Zalm
7 years ago

Thanks very much David, this was really helpful for me!