How to set an ad to appear only on your Mobile version Desktop of a Website

WordPress not for a long time a simple blogging platform. It allows us to develop from simple blogs with a minimalist design up to portals si Forums complex or even online 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 devices, tablet or desktop.

WordPress users who want certain ads or items to be visible only on the mobile version or only on the mobile version desktop of a web page, they have at hand a very simple WordPress function.

How to set an ad to appear only on your Mobile version Desktop of a Website

function "wp_is_mobile"Helps us to force an element (an advertisement in our case) to appear only when the website is accessed from a mobile phone Android, iOS or Windows Mbl.

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

if ( wp_is_mobile() ) {
	cod_reclama_sau element

Another option is to put the code between PHP functions:

<?php if (wp_is_mobile() ) { ?>
<?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 the ad should be visible only on the version desktop 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() ) { ?>
<?php }?>

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

How to set an ad to appear only on your Mobile version Desktop of a Website

About the author


Passionate about everything that means gadget and IT, I am pleased to write on from 2006 and I love to discover new things about computers and macOS, Linux operating systems, Windows, iOS and Android.

Leave a Comment