How to Create a Page Template for a WordPress Website

Reading Time - 2 minutes
wordpress page template
WordPress Screenshots / CC BY-SA 3.0
Creating a WordPress Page Template

A template is a PHP file stored in your website’s WordPress directory that contains information WordPress needs to format your pages in a specific manner. For example, if you want all the posts in a specific category on your website to have a particular format that is different from the default format, you can create a custom page template and upload it to your directory. Once uploaded, the page template will become visible within the WordPress content management system, where you can select it before publishing a page to easily format the text and images contained within.

Step 1

Open Notepad, the default text editor included on all versions of Windows. Click “File,” then “Save as.” Enter the name of the page template that you’re going to make into the text field, then add “.php” to the end of the name. For example, if your page template is named Template, the file should be saved with the name “template.php.”

Step 2

Type the following code at the top of the text file, which is necessary for WordPress to recognize it as a page template: Once entered, save the changes. Beneath the text in this file, you can enter the page template information you want using WordPress’ custom coding and standard PHP. You can enter the code that affects only a small portion of the page, or you can create a PHP script that alters all the elements on the page. Once you’ve created the PHP template that you want, click “Save,” then close Notepad.

Related:  Web Design Project Lifecycle
Step 3

Open your WordPress directory using either your favorite FTP application or your website host’s online FTP Java app. Transfer the PHP page template file that you create into the “Themes” folder within the WordPress directory. Make sure the file has transferred in its entirety before you close the FTP program.

Step 4

Log in to your WordPress control panel and either select one of your existing pages or create a new page. At the bottom of the page, choose the new page template that you created from the “Template” drop-down menu.

About Norman Anthony Balberan

I am a Bachelor of Science in Pharmacy graduate turned full-time web developer and designer. Although my professional background is in pharmacy and tech, I have a passion for writing and am excited to share my insights and thoughts through my blog. I write about various topics that I am knowledgeable and passionate about, and I hope to engage and connect with my readers through my writing.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.