Archived topic
Display Adsense based on Device?
6 replies · Started by Andy on August 20, 2021
Hi there,
I have 2 snippets of Adsense code. One for desktop and one for mobile.
I want to add both code snippets to the same article. However, I want one Ad to show only in desktop view, and the other Ad to show only in mobile view.
How do I accomplish this inside a blog article?
Thank you
I'm assuming the logic would be to hide my code snippets based on device type. But, I'm having a hard time figuring that out within a blog article.
And I'm trying to add several code snippets throughout the article... so hooks are out of the question.
Hi Andy,
The easiest way I can think of is to use CSS to hide one or the other but the ads would need to have specific classes for us to target.
If that doesn't work then you would need to find a way to modify the Adsense code to achieve your goal.
This isn't something we can help with in this support forum as it's not theme-related.
You could also try asking the question in a WordPress general forum like this:
https://wordpress.stackexchange.com/
Thanks for your understanding :)
Thanks Leo,
The easiest way I can think of is to use CSS to hide one or the other but the ads would need to have specific classes for us to target.
In this example, if I can add classes to the snippets, what would be the CSS code to hide in desktop view OR hide in mobile view? (im assuming this question is theme-related support)
Thanks Leo
No problem :)