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, the "life" of a large website can only be supported from 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.

users WordPress 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 a function at hand WordPress very simple.

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

Function “wp_is_mobile"It 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 Mobile.

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

<?php
if ( wp_is_mobile() ) {
	cod_reclama_sau 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 the ad should be visible only on the version desktop of the web page, in front of “wp_is_mobile” will be put “!”, which will determine that the following content will be visible on all devices, except on 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.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » Ads / Marketing » How to set an ad to appear only on your Mobile version Desktop of a Website
Leave a Comment