Create Custom Page Template

Last Updated: August 25, 2020

If you need a different page layout for your page then you have to create a custom page template in WordPress. 

So a custom page layout will have a different look than your regular page template.

Creating a custom page template is very for your theme and in this post we will see how to create a custom template for your website.

How to create WP custom page template

When you browse the file in your theme folder you can see a php file called page.php. This is the default template file for any page you create in your WordPress theme. So when you create any page in your website this template will be automatically assigned.

You need to have basic knowledge of HTML, CSS and PHP to work with template files.

Now we will see how to create a WP custom template.

To create new page template you can use your favorite editor and just create a php file and save it as custom-page.php

Now you can add the following code to page you created

/* Template Name: Custom Page */


Now you can upload the file to your current theme folder

Try to create a new post or edit an existing page. You can select the page template under the Page Attributes  as shown the following image

Custom Page Templae
Select Custom Page Template
        /* Template Name: Custom Page */


<main id="site-content" role="main">


    if ( have_posts() ) {

        while ( have_posts() ) {

            get_template_part( 'template-parts/content', get_post_type() );


</main><!-- #site-content -->

<?php get_template_part( 'template-parts/footer-menus-widgets' ); ?>

        <?php get_footer(); ?>

You can use this template as the starting template for your custom page template. It has got the basic components like header, content, sidebar and footer. You can change the layout of the page using HTML and CSS, in addition to that you can define additional widget area and other components according to your requirements