WordPress custom page template

Templates let you modify the way WordPress displays your pages and they are great for creating a consistent style across your site.

Creating the template code

Navigate to your /wp-content/themes/your-theme folder and create a file called sample-page.php. Copy the code below and put it in your sample-page.php file.

<?php
/**
Template Name: Sample Page 
*/
get_header(); ?>
<div id="primary">
    <div id="content" role="main">
        <p>Sample Page!</p>  
    </div>
</div>
<?php get_sidebar();?>
<?php get_footer();?>


There won’t be too much on the new template but It will be a good starting point for you to customize your own.

Selecting the template

Now that the template has been created, edit an existing page or create a new one and look for the page attributes pane. Click on the template drop down box and you should see the new template we created. Click on the “Sample Page” template to apply it to the page.
custom