Tuesday , 18 June 2019
Home / Programming / WordPress / Themes / Custom Templates – WordPress Theme Tutorial
Custom Templates
Custom Templates

Custom Templates – WordPress Theme Tutorial

This tutorial is a part of the WordPress Theme tutorial series. If you would like to see the whole series and the order in which you should follow them, then click here.

By creating our own templates for certain pages, we make our theme dynamic and flexible. Though, in some situations you’ll want to create a template that WordPress isn’t aware of. For example, our page template is one way to display a page, but what if we wanted a full width page instead of one with widgets. We still want to keep the page with widgets, but we want the user to decide which one to use.

This is actually quite simple to do. Open up your page.php file and save it as custom-template.php. You can actually name this file any name you want. Just as long as it isn’t reserved for a certain post type in WordPress. Let’s update the code to this.

As you can see, we removed the sidebars for our page. We also have to add a file header at the top wrapped in comments. All you need to do is give the template name. This will be displayed to the user when they choose a template.  In order for our users to use this page, they have to select it when they’re creating a page. Try creating a page and on the side, you should see an option to select a template.

Custom Template
Custom Template

Save your post and then try viewing it. You should see the difference. If the user doesn’t specify a template, then WordPress will automatically choose one for them.


You can create as many custom templates as you want. You can create a template for portfolios, recipes and even business directories. The choice is yours.

About Jasko Koyn

Check Also

How to add JavaScript in your WordPress Themes

How to add JavaScript in your WordPress Themes

We have some javascript in our theme. So, let’s learn how to add JavaScript in …

Leave a Reply

Your email address will not be published. Required fields are marked *

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