PHPMatters Help You Better Hosting Your PHP-based Sites
Simple Steps to Create a WordPress Custom Page Template

Simple Steps to Create a WordPress Custom Page Template

As is known, the page is a kind of WordPress post types, and most of them look the same. In some cases when you need some completely different looking pages to celebrate a date or something else, then you may consider creating a new custom page template. Plus, it is the easiest way to set your preferred page location, title and description at the top of the WordPress site.

Objectively speaking, to create a new WordPress custom page is not difficult even for people who are not acquainted with a series of coding stuff. Instead, you only need the access to a server and use a text editor to perform the whole process. At this place, we’ll have a concise and clear explanation on how to create a WordPress custom page template step by step. Drop down and learn more detailed steps.

Some Prerequisites Before Starting out

As template files couldn’t be created from the dashboard of WordPress, you have to get access to your own server. If you are not pretty sure whether you are permitted to access the server, then you will need to contact the web host.

Normally a trustworthy web host can not only give full root access to a server, but also is responsible for technical issues you have encountered afterwards. In this sense, it is imperative to use reliable hosting service, and in the following, there are some recommendable options based on our investigations.

How to Create a WordPress Custom Page

Back to our point, we would like to illustrate how to create a custom page by taking the industry-leading cPanel control panel as example in below. Having successfully entered the user interface of cPanel, you can refer to the following steps.

Go into File System
As is displayed in the screenshot, you need to click the “”File Manager” button in “Files” section to enter the file system where there are all kinds of WordPress files.

WordPress Custom Page Template - File Manager

Navigate to WordPress File Directory
Once done, navigate to the file folder where your WordPress has been installed. Then, go to the root of /wp-content/themes/. As is displayed, you need to double click the “themes” option placed on the right column so as to choose the theme that you are using now.

WordPress Custom Page Template - WP Content

Find out a “page.php” Template File
Having accomplished the steps above, you will notice that there is a long list of editing options under the theme folder. All you need is to find out a template file named as “page.php” at the bottom of the page. Remember to make a copy of this “page.php” file before editing it by clicking the “Copy” button.

WordPress Custom Page Template - Twentythirteen Theme

Once done, you are required to open this default “page.php” file and copy all codes inside it. Note that you can also choose “Download” it to the local computer and open it with script editor like Notepad++.

Create a New Template File
Next, you will have to create a new template file for the new custom page. To do so, you can click the “New File” button lying on the top of the management page. Beware that this new file should end with a “.php” extension, and you’d better name it in the form of “-page.php”. Here, we create a new template file called “custom-page.php”. At last, check whether the file root is right and click “Create New File” button to go on.

WordPress Custom Page Template - New Template File

Paste Materials into the New File
Then, you will need to open the newly created “custom-page.php” file by choosing “Edit” it. In the meantime, you are requested to paste the copied information from the default “page.php” template file into this new file.

WordPress Custom Page Template - Copy Information

Create a Name for Page Template
Of course, you shall add the following codes to this newly-created file to name your custom page template. As you can see, we have given the new page template the name of “My-New-Page-Template”. Note that you should put those lines of codes before “get_header(); ?>”.

Template Name: My-New-Page-Template

You can also refer to the following screenshot.

WordPress Custom Page Template - Create Template Name

Once completed, click “Save” button to put it into effect. In this way, we have created a custom page template by using an existing page, which is much easier than writing all codes from scratch. By the way, there is no need to use dashes to separate each word, and you can use spaces directly.

How to Customize a Custom Page Template

Having created a new page template successfully, you are supposed to customize it. To be frank, to customize a page template varies from people to people. For instance, you are allowed to add appealing themes or personalized sidebars to the new template page. At this place, we would like to show some basic customizations on a new page template in below.

Add a Red Line of Text
To test whether the newly-created template page works, we would like to place a red line of text in the center of the page. To do so, you only need to paste the following codes after the code of <div id=”content” class=”site-content” role=”main”/>.

<p align="center"><font color="#FF0000" size="5" face="Arial">This is my custom page template. How do you like it?</font></p>

Pay attention that all changes should be made in the new template file of “custom-page.php”.

WordPress Custom Page Template - Custom Page Template

It is obvious that we have created a new page template, which may look the same as the default one. To make the current template a little bit different from the old edition, we’ll try to customize the page width in below.

Customize the Width of Page Template
Go back to the dashboard of WordPress and follow the root of “Appearance > Editor > My-New-Page-Template Page Template”. Next, choose the “Stylesheet” option and enter the following codes at the bottom of the editing page.

#page-test { width:100% }

In the meantime, add a new line code of like

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

WordPress Custom Page Template - Customize Page Width

Choose Page Template from Drop-Down List
To sum up, there is no universal method to customize a page template, and it is up to personal preference. Undoubtedly, you can use the new template by entering the section of “Add New” in “Pages” and choosing it in the drop-down list on the right side. Details are displayed as follows.

WordPress Custom Page Template - Drop Down List

Notes: Of course, you can choose to create a page or post template for the single post by using certain powerful WordPress plugins, such as WP Custom Post Template. Pay attention that you should have the custom page/post template files in the same folder/directory as the “index.php” file, rather than in a sub-folder or sub-directory.