Site logo

Archived topic

exclude contents from mobile homepage

1 reply · Started by Christoph on October 15, 2015

Viewing posts 1–2 of 2

Is it possible to designate contents so that they are only shown (and loaded) in the desktop version of the Homepage, but not in the mobile version, or reversely?

That´s the content i mean:
<iframe src="https://www.google.com/maps/embed?pb=!1m0!3m2!1sde!2sat!4v1444925737391!6m8!1m7!1sTza-G1Dtb-IAAAQo8Yi0tw!2m2!1d48.19960859499133!2d16.35728957905712!3f143.14494327750967!4f-15.08425043733483!5f0.7820865974627469" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

Hi Christopher. You could display the content in a number of different locations using the GP Hooks Add-on and this code:

<?php
    if ( is_home() ) { ?>
        <div class="my-iframe">
            your iframe code goes here
        </div>
<?php } ?>

Make sure to check the "Enable PHP" checkbox on the hook.

Then use this CSS to hide it in mobile views:

@media (max-width: 768px) {
    .my-iframe {
        display: none;
    }
}

To hide it in the desktop view instead, change "max-width" to "min-width".

Adding CSS: https://generatepress.com/knowledgebase/adding-css/

This archived topic is closed to new replies.