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?
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
Edit:
You can also setup a new page which will get post depending on ID.
First lets create custom-template
it should give you back your post
Of course you need to design your own template.