Adding a Template to a WordPress Theme

WordPress version: 3.5

Create a php-file in the theme folder, with whatever name you choose. E.g.

MyTemplate.php

The php-file has to contain at least the following code to be recognized as template:

<?php
/*
Template Name: A Nice Template Name
*/
?>

Replace the string “A Nice Template Name” with whatever string by which you want it to be selectable. The string can contain spaces and special characters. The template now will be recognized by WordPress and you can choose it, for example, as template for a new page. The template will be selectable by the name “A Nice Template Name”. It just would not display anything.

Usually a template is aligned with the theme by using the themes header and footer at least.

<?php
/*
Template Name: A Nice Template Name
*/
get_header();

get_footer();
?>

Comments are closed.