Block Ads in WordPress, while mobile view

Hi there,
Quite recently I’ve created a native app (webview app)of my wordpress website and this wordpress site is using responsive theme as well. Now I want to publish this app at play store. The problem is that Adsense are not allowed to be shown in a native android app. So I want to know how I can block adsense in this native android app? as I will place admob in this android app. I searched a lot but could not find that how I can do this? Adsense are showing in mobile view of my website but I want that these adsense would not show in mobile view, specially in android web view.

thanks in advance

It depends on how your AdSense code is added to your WordPress site.

If you added the code in your theme .php files, you may use the wp_is_mobile() to detect the users’ browser and decide whether to show or not show the AdSense ads.

If you added the code to your sidebar as text, you may try the widget logic plugin to control whether you will show an widget depending the true of false of a piece of php code.

If you added the code by using 3rd party plugins, you will need to check whether these plugins have an option to control when and whether to show the code.

Note that if you are using some caching plugins such WP Super Cache, you will need to configure the plugins to cache mobile and normal views differently. For your reference, in WP super cache, it is called “Mobile device support”.

Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *