Skip to content

Instantly share code, notes, and snippets.

@nickdavis
Created October 21, 2014 19:28
Show Gist options
  • Save nickdavis/ac2f20d9821303c390e9 to your computer and use it in GitHub Desktop.
Save nickdavis/ac2f20d9821303c390e9 to your computer and use it in GitHub Desktop.
Add a 'full width' iFrame (WordPress) page template using a custom field for the iFrame URL and including Genesis scripts (if set) in the header
<?php
// Template Name: iFrame
/**
* Get the URL for the iFrame from a custom field
*
* @link http://www.billerickson.net/advanced-custom-fields-frontend-dependency/
*/
$url = esc_url( get_post_meta( get_the_ID(), 'iframe', true ) );
/**
* Display a full page iFrame and strip out all other content on the page
*
* @link http://www.dev-explorer.com/articles/full-page-iframe
* @link http://www.billerickson.net/full-width-landing-pages-in-genesis/
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php the_title(); ?></title>
<style type="text/css">
html {overflow: auto;}
html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
</style>
<?php
// Add any Global or Single scripts set in Genesis options
genesis_header_scripts();
?>
</head>
<body>
<iframe id="tree" name="tree" src="<?php echo $url; ?>" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"></iframe>
</body>
</html>
<?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment