I would like to load a WordPress post into an iframe when a link on a WordPress page is clicked. This is the link I currently have.

<a href="' . get_post_permalink($sight->ID) . '" target="map-loader">Read the report</a>

Then I want the content of that post (no header or footer etc) to load into an iframe when the link is clicked. This is the iframe that is on the page.

<iframe name="map-loader" src="map-iframe.php"></iframe>

I am half way there. When the link is clicked, the iframe loads a full wordpress page with the header and footer etc. what I want is the actual post content to be loaded into the iframe, no header or footer.

I have tried this in map-iframe.php but no success. Still loads the whole wordpress template.

<?php the_content('Read the rest of this entry »'); ?>

I'm thinking that my link needs something that specifies that I only want to load the post content.

Or would it be better to load with ajax?

1 Answer 1


Not sure, but I think ajax solution would be more apropriate.

But anyways, if I understand this corectly, you have an archive where full posts are loaded inside iframe.

If this is a case you can modify template file (single.php) and remove header and footer

take a look at Template Hierarchy

for further reading I found this which will guide you to more advanced features:http://bavotasan.com/2009/custom-template-for-single-posts-in-wordpress/

Note: if you also want to get rid of adminbar, try this: show_admin_bar(false); at the top of your code.

Have not tested but if this does not work, you can hook inside init and check

if(is_page()) {


You can also setup a new page which will get post depending on ID.

First lets create custom-template

  • In your themes folder create file template-iframe.php (for example)
  • put this code inside

* Template Name: IFrame
   $id = intval($_GET["ID"]);
   $post = get_post($id);
  • Then go to dashboard and create page iframe and in the sidebar where it says: template, choose now created template (Iframe)
  • save and go to url and time http://yoururl.domain/iframe/?ID=1

it should give you back your post

Of course you need to design your own template.

  • Thanks but not sure if that is what I want. Adjusting single.php will change all my posts. I have a page that contains links to some posts. When those links are clicked, I want to load the content of the post in either an iframe or a div with ajax. Think of it as loading a little preview of the post content in a light box. Meanwhile all other posts still need the full template when they are viewed under normal circumstances on other parts of the site. Jan 25, 2014 at 9:28
  • see edited version, write back if you need more info
    – CBeTJlu4ok
    Jan 25, 2014 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.