I want to create a blank template to include a full page

Hello!
I want to create a blank template to include a full page iframe. I've tested the following code:

<?php
/*
Template Name: framed
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>CODE FOR THE TITLE</title>
	<style>
        body{
            margin: 0;
        }
		iframe{
			width: 100%;
			height: 100%;
			border: 0;
            position: absolute;
		}
	</style>
</head>
<body>
	<iframe src="http://anysite.com" frameborder="0"></iframe>
</body>
</html>

This works very well in the sense that it actually shows the site in the template.
The actual question, is how to add a code that calls the content and the title. I want to create pages based in this template, but I want to add the adequate iframe to each new page I create (in the editor). The content of each page would be:
<iframe src="http://anysite.com" frameborder="0"></iframe>

Where anysite.com would change from page to page.

Thanks for your help!

  • Vinod Dalvi

    Hi Luis,

    I hope you are well today and thank you for your question.

    You can try using the following template code which will display the content and the title of the page so that you can add the iframe code in the page content which will be display in the front end.

    <?php
    /*
    Template Name: framed
    */
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title><?php the_title(); ?></title>
    	<style>
            body{
                margin: 0;
            }
    		iframe{
    			width: 100%;
    			height: 100%;
    			border: 0;
                position: absolute;
    		}
    	</style>
    </head>
    <body>
    		<?php while ( have_posts() ) : the_post(); ?>
    	<h1 class="entry-title"><?php the_title(); ?></h1>
    	<div class="entry-content">
    		<?php the_content(); ?>
    	</div>
    	<?php endwhile; // end of the loop. ?>
    </body>
    </html>

    I recommend you to use the default WordPress get_header and get_footer functions as displayed below.

    <?php
    /*
    Template Name: framed
    */
    get_header(); ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    	<h1 class="entry-title"><?php the_title(); ?></h1>
    	<div class="entry-content">
    		<?php the_content(); ?>
    	</div>
    	<?php endwhile; // end of the loop. ?>
    <?php get_footer(); ?>

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.