How to add Anti-AdBlock Script in Wordpress

Are you looking to enhance your revenue potential on your Wordpress website by preventing Adblockers? If so, this article is tailored for you.

How To Add An Anti Adblock Script In Wordpress? Within these pages, I'll guide you through the simplest method of detecting Adblockers in Wordpress and compelling users to disable them on your site.

But first, let's clarify: What exactly is an Adblocker, and why should you consider employing an Anti Adblocker script on your website?

How to Install an Anti-Adblocker Script on Your WordPress Website

Adblockers primarily function as browser extensions engineered to intercept and block ads from appearing on web pages, effectively stripping them of ad content.

Now, why does this matter? Well, when a user employs an Adblocker extension, any ads present on your site won't be visible to them. Consequently, you lose out on potential ad clicks and impressions from their visit, which can significantly impact your overall ad revenue.

Anti Adblock script for WordPress (without Plugin)

This issue has grown increasingly pressing as more individuals opt for a cleaner browsing experience, albeit at the expense of creators like us who rely heavily on ad-generated income.

Even major online platforms such as Google, YouTube, and Facebook heavily depend on ads. As a content creator, encouraging your audience to disable Adblockers becomes crucial. After all, considering the content is provided free of charge, encountering a few ads shouldn't be a major inconvenience for users.

After recently publishing a video on adding an anti-adblock script to Blogger, I received several requests for a tutorial on implementing it on WordPress websites. Follow the step-by-step guide below to accomplish this:

How to Install Anti Adblock script in Wordpress?

To install the anti-adblock script in WordPress, first, log in to your dashboard and navigate to Appearance > Theme File Editor. Next, open the Footer.php file and locate the </body> tag within it. Once found, paste the script just above this tag. Finally, update the theme code, and the installation is complete.



<style>
.note{position:relative;padding:20px 30px 20px 50px;background-color:#e1f5fe;color:#01579b;font-size:.85rem;line-height:1.62em;border-radius:2px}
.note:before{content:'\2605';position:absolute;left:18px;font-size:20px}
.noteAlert{background-color:#ffdfdf;color:#e65151}
.noteAlert:before{content:'\2691'}
</style>
<script>//<![CDATA[
!function() {function f() {var a=document.getElementById("main");a.innerHTML='<p class="note noteAlert blocked"><strong>Ad-Block Detected :((</strong><br><br>Sorry, We detected that you have activated Ad-Blocker. <br> Please Consider supporting us by disabling your Ad-Blocker,It helps us in maintaining this website. <br>To View the content disable adblocker and refresh the page.<br><br>Thank You !!!</p>';} var b=document.createElement("script");b.type="text/javascript";b.async=!0;b.src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";b.onerror=function() {f();window.adblock=!0};var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(b,e)}();
//]]></script>

If the provided code snippet does not function properly, you need to replace the ID (e.g., main) of your main content as utilized in your theme.




If you prefer not to integrate it directly into the theme file editor, consider employing a code manager plugin such as Header Footer Code Manager on your website.

Header-Footer-Code-Manager-WordPress-plugin
This plugin facilitates adding code to the footer section of your WordPress website.

If you utilize an AdSense plugin like AdInserter, you can utilize it to add the code to the footer section as well.

Simply input the code into one of the designated boxes and configure the placement to the footer.


Implementing an anti-adblock script in WordPress allows for the identification of Adblocker users on your website and encourages them to disable the adblocking tool.

Best Anti Adblock WordPress Plugins

If you prefer not to utilize a script, you have the option to directly integrate an anti-adblock plugin into WordPress. Here are the top 5 plugins you may consider:

1. Ad Blocker Notify
2. AdBlock X
3. Ad Blocking Detector
4. Simple Adblock Notice
5. Block AdBlock

Note that while some of these plugins may not be tested with the latest WordPress version and due to frequent evolution of adblockers, they may not function optimally in certain cases.

While these plugins serve the same purpose as the aforementioned script, they present adblock notices differently, showcasing various styles of warning messages to users. However, I recommend using the script mentioned earlier for its efficiency and avoidance of the need for an additional plugin.

Anti-ad blocker plugins, also known as anti-adblockers or ad-blocker blockers, are tools or scripts utilized by website owners and marketers to detect and prevent individuals from using ad-blocking software when visiting their sites. Ad blockers are browser add-ons or applications that users install to prevent online advertisements from appearing.

The primary function of an anti-ad blocker plugin is to identify when a user attempts to access a website while using an ad blocker. Subsequently, it may prompt the user to disable the ad blocker or restrict access to content until the ad blocker is deactivated. These actions may involve displaying messages to users requesting them to "whitelist" the site, blocking access to specific content, or imposing limitations on website usage.


Should you encounter any issues during this process, feel free to ask in the comment section. How to set powerful Anti Ad Blocker for Blogger and WP?

Remember to share this article with your blogging community to help them enhance their earnings.

FAQs About Anti-Adblocker for WordPress:

How do I add ad blocker to WordPress?

To swiftly add a new Ad block, simply type "/ad" on a new line and then press enter. For additional guidance on working with blocks, refer to our detailed instructions on adding blocks.

How do I add an ad script to WordPress?


To begin, log in to your WordPress admin dashboard. Then, navigate to Plugins > Add new. Search for the "Insert Headers and Footers" plugin, install it, and activate it.

Once activated, proceed to Settings > Insert Headers and Footers in the dashboard menu. Paste the Google AdSense verification code into the Headers section, and ensure to save the changes.