Creating a New Page Template requires us to do 4 things in order to make things work, but first we’ll create a new .php file in the theme directory (/wp-content/YOUR-THEME/), such as page-homepage.php.

  1. Specify a page template name.
    <?php /* Template Name: Homepage */ ?>
    
  2. Include the header
    <?php get_header(); ?>
    
  3. Start the WordPress loop on the desired page & print the content
    <?php
    // Start the loop.
    while ( have_posts() ) : the_post();
        // Include the page content template.
        the_content();
    // End the loop.
    endwhile;
    ?>
    
  4. Include the footer
    <?php get_footer(); ?>
    

Full Code Example:

<?php
/* Template Name: Homepage */

get_header();

while ( have_posts() ) : the_post();
    // Include the page content template.
    the_content();
// End the loop.
endwhile;

get_footer(); ?>

 

 

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!