Remove content if loaded in iframe?

I’m currently working on a wordpress onepager and I want to open all wordpress posts in an iframe. This works fine, but the header and footer still appear in this iframe.

In WordPress’ single.php there are these two lines:

Read More
<? get_header(); ?>
<? get_footer(); ?>

If I delete them, header and footer are gone, which is great, but as soon as I open the link directly and not in an iframe it looks totally naked without stylesheet, header, etc.

Is it possible – maybe with php – to remove these two lines ONLY if the site is being loaded in an iframe?

Related posts

Leave a Reply

1 comment

  1. the url you are using in the iframe:
    I’m assuming it’s would be something like single.php
    Change it to single.php?iframe=yes.

    OR
    If you have single.php?id=whatever
    Then change it to single.php?id=whatever&iframe=yes

    in single.php use

    if (!isset($_GET["iframe"]) get_header();
    if (!isset($_GET["iframe"]) get_footer();