Archived topic
Show different adverts to mobile and desktop users
7 replies · Started by Adam on September 9, 2019
Hello,
We use the elements options in the Generate Press theme to show adverts on our site. Is there any way to create elements that detect the users device and show diffent styled adverts based on the device they are using (e.g. desktop and mobile)?
Many thanks!
Adam
Hi there,
Are you using an Ad services such as Adsense ? If so then you would choose a responsive ad format. Using PHP to select a different advert is a bit hit and miss.
Thanks David.
The adverts are direct from clients rather than AdSense. So a 728 x 90 header image looks good on desktop but not so good on mobile.
How are the adverts provided? Is it just a block of HTML and CSS?
Hi David. Yes it's just a block of html and CSS
The simplest but not necessarily the most efficient way is to add all the various HTML blocks for each advert size and add the hide-on- classes to leave the one you want displayed on each device:
https://docs.generatepress.com/article/responsive-display/#using-our-hide-on-classes
Thank you!
You're welcome