Thursday, September 22, 2011

How to Create Custom WordPress Page Template

Readin makes the difference.

I always wanna be a Wordpress guru and i think there is just a small time ahead.

I would than be able to create my own Content managment system thats why i do a lot of study and search over the net and got intereting things about the CMS's..

Today im going to write here the way to create custom page template for the wrodpress..

Lets Start that How to Create Custom WordPress Page Template

Here is some thing i have got from different sites .

"

WordPress Page Templates may be easier than Category Templates. WordPress looks for templates in the following order:

  • 1. The Page’s selected “Page Template”

  • 2. page.php

  • 3. index.php


Let’s pretend we want to create a specific template for an “About Us” page. Most themes will have a page.php so once again, you can copy your page.php and resave it, let’s call it about.php.

Once resaved, our page template must start with the following 5 lines of code so add the following to the very top:

<?php
/*
Template Name: About
*/
?>

 


"To use the template simply go to the write page screen, find the "Page Template" panel, and select the template you want to use. Hit save and the page will be formatted using the new template.

Once this is done you can change the template file to do anything you like. Below is a very simple example of an archives page template.

<?php /* Template Name: Archives
*/ ?>

<?php get_header(); ?>

<h1>Archives</h1>

<h2>Archives by Subject</h2>
<ul>
<?php wp_list_cats(); ?>
</ul>

<h2>Archives by Month</h2>
<?php wp_get_archives(); ?>

<?php get_footer(); ?>


Archives aren't the only thing the custom page templates are good for - you can use them for many different things - for example you could make a custom contact page with a contact form, or a new style of links page using the built in blogroll features.

1 comment: