WordPress / Web Development Tutorials
(Best WordPress Tutorials)

Silva Web Designs - Blog

How To Create a WordPress Custom Page Template

In this tutorial, we are going to show you how you can create a custom WordPress page template for your theme.

What are custom WordPress templates?

WordPress custom page templates are theme files that provide an alternative to the default page.php file. These custom templates can contain whatever HTML and template tags you wish to build your desired layout or content, then the file can be attached to a specific page in order for WordPress to use this new template when serving that particular page of the site.

Common uses for custom page templates are to create unique page layouts, e.g; for about page, services page and contact page. If you need to configure your page layout beyond what is available in the default page.php file, a custom page template is what you need.

How to create a custom page template?

Creating a custom page template is easy! Create a blank PHP document and add the following code:

Template Name: About

Configure the template name to something recognisable (e.g. page-about.php). The ‘Template Name’ is what will appear in a drop-down menu within the WordPress admin screen.

In the remainder of the document add your HTML and WordPress template tags to construct your desired layout. This might utilise tags such as to build the page using the existing header/sidebar/footer elements, or you might be building something completely unique using a complete WordPress loop. Don’t forget, you can also hard code features into your template file that are unique to this page, such as a contact form, YouTube video or a Google Maps API.

Once you’ve created your custom page template and uploaded it to your theme directory, create your page using the WordPress editor. Any content you add using the WYSIWYG will appear wherever the tag was placed within the template. This page will use the default page.php template unless you change the Template option under Attributes:-

Select the Template menu and choose the template file with the name you supplied. Hit the publish button and see your WordPress content dynamically generated using the structure of your custom page template.

It’s as easy as that! πŸ™‚


Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital-related. His main expertise is with WordPress and various other CMS frameworks. If you need responsive design, SEO, speed optimisation or anything else in the world of digital, you can contact Silva Web Designs here; [email protected]

It’s good to share

Join the discussion