Thord Daniel Hedengren - Smashing WordPress_ Beyond the Blog-Wiley (2014)

(avery) #1

98 PART II • Designing and Developing WordPress Themes


Figure 4-8: The hierarchy of template files.

PAGE TEMPLATES
WordPress Pages are meant for static content that is less time-dependent than your average
blog post (which probably is static, after all). Pages can have subpages, which are typically
used for information about the site, contact forms, and so on. However, you can take it way
beyond that if you want to. First, you can give the page.php template a nice styling that fits
the kind of content you want to display on your Pages (rather than just have them mimic
your blog posts). Second, you can create Page templates that you can apply to individual
Pages from the Write page section in the WordPress admin.

These Page templates are basically normal template files, except that they need a little code
snippet at the top of the file before the actual code begins so that WordPress can find them
(much like your theme’s style.css, in other words).

Just put the following lines on top of the Page template file, which you can name whatever you
like as long as it is suffixed with .php:

<?php
/*
Template Name: My Page Template
*/
?>
Free download pdf