Creating a Custom Page Template in WordPress

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

In this tutorial, we will create a custom page template in WordPress.  After duplicating the Twenty Fourteen theme and calling it “Twenty Fourteen Custom”, we make a copy of the default page template page.php and call it page-twocolumn.php …

custom template

custom template

We added some custom template code to page-twocolumns.php as shown above.  This code will render two columns below the normal post.

But the key in creating a custom template is at the top of the page-twocolumns.php file.   We have to put “Template Name” and the name of the custom template in the commented section as shown here …

specifying template name in custom template

specifying template name in custom template

That way, when you go create a new page, you will be able to select the custom template from the template selection droplist…

custom template available in new page

custom template available in new page

You can only have custom template for pages, not posts.   After selecting Two Columns for the template, we publish the page can see the render of the code in our custom template ….

render of custom template

render of custom template