Creating a page template
It’s easy to generate your own custom pages and include any code you wish. Once created, you select which page template to use in the write/edit page sidebar.
The code
Begin by duplicating your index.php or page.php file in your template folder - rename the file to anything you wish, I usually name my customer template files ‘template_customname.php’ replacing ‘customname’ with something a bit more descriptive!
Care should be taken not to use a filename that clashes with the template file system of WordPress. These file names are recognised by WordPress to be used in certain situations.
Now simply put the code below right at the top of your new file.
<?php /* Template Name: My custom page name */ ?>
Now you can select the page template ‘Custom Name’ from your edit/write page sidebar. You will only get this template file selection when you have a custom page template file.
Once you have confirmed that this is working, you can go ahead and include any content, php, custom queries you wish into your new template file. This is particularly good when you don’t wish to use the strange tags whilst editing pages for plugins - just code it directly into the page template, and you can re-use it on other pages.
Relevant links and further reading
WordPress Codex - Pages
WordPress Codex - Creating page templates
Intresting article comparing WordPress to other CMS systems »







Comment from Webseiten Optimierung
Time: December 21, 2007, 9:35 pm
Huhu, ich finde deinen Blog wirklich informativ und moechte nur sagen WOw. Einige Infos wuerde ich gerne genauer nachlesen. Falls du Quellenangaben ueber diesen Beitrag hast, waere es echt lieb von dir, mir Diese mitzuteilen.