How to set up an ad appear only on mobile or desktop version of a website

WordPress not for a long time a simple blogging platform. It allows us to develop from simple blogswith a minimalist design up to portals si Forums complex oronline shops blown, thanks Pluginacquis WooCommerce and other the E-Commerce which can be integrated into WordPress.

Except sites presentation of companies and the nonprofit which are supported by various entities, "life" of a website proportions can not be sustained than in advertisement or products / services that it sell them. It is the same thing as with televisions that are supported solely by advertising.

Diversity can be listed devices are on an advertisement (banner) on a website, it forces it to be visible in the optimum, whether web page that is accessed from ad found mobile, tablet or desktop.

WordPress users who want certain advertisements or items to be visible only on the mobile version or only on the desktop version of a web page have a very simple WordPress feature.

How to set up an ad appear only on mobile or desktop version of a website

function "wp_is_mobile"Help us to force an item (an advertisement in our case) occur only when the website is accessed from a mobile phone Android, iOS or Windows Mobile.

Here's the code for an advertisement to be visible only on mobile:

<? php if (wp_is_mobile ()) {code_reclama_or element}?>

Another option is to put the code between PHP functions:

<? php if (wp_is_mobile ()) {?>
cod_reclama_sau_element
<? Php}?>

In this way, the creative code will only be visible to browsers identified as a mobile device.

In the scenario where we as a ad to be visible only on the desktop version web page, in front of "wp_is_mobile" will put "!", which will cause the following content will be visible on all devices, except the mobile version.

Example code:

<? Php if (! Wp_is_mobile ()) {?>
cod_reclama_sau_element
<? Php}?>

This way you can manipulate elements on a web page, depending on which device is accessed.

How to set up an ad appear only on mobile or desktop version of a website

About the author

Stealth

Passionate about everything that means gadgets and IT, I write with pleasure stealthsettings.com from 2006 and I like to discover with you new things about computers and operating systems macOS, Linux, Windows, iOS and Android.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment is processed.