Creating custom page template in WordPress

Creating custom page on WordPress is prety simple. You can create custom page on your wordpress with content what ever you want. In this sort tutorial, I’ll explain you how to create pagethat consist of archive, categories and blogroll page. This will usefull if you have a lot of archive or you have a lot of link on your blog roll and you dont want showing this on your sidebar.

preview Creating custom page template in WordPress

step 1

Look for index.php file or page.php file on your themes folder , copy and paste on your themes folder renamed with archive.php.

Remember, you can used your existing themes or download free themes on the internet, for this tutorial I using my simple themes that I create on the previous post and I using index.php file for starting.

step2

On the beginning archive.php, add the following piece of code

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

step 3

Found the wordpress loop within the file delete and remove piece of code bellow

<?php the_content(”); ?>

for more detail, on my archive.php, I have code like this

<div id="content">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span class="postDate"><?php the_date('F j, Y'); ?> in <?php the_category(', ') ?> by <?php the_author() ?></span>
<div class="entry">
<?php the_content('more'); ?>
</div>
<?php comments_template(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>

Remove code within element with id content. By now I have somethink like like this

<div id="content">
<!--archive page!-->
<h2>Monthly Archives</h2>
<ul><?php wp_get_archives('type=monthly') ?></ul>
</div>

What Im doing on the sourcode above is, replace post loop with ‘archives’

step 4

Save your archive page, go to your wordpress admin page, and create new page, on the title give name archives.

step4 300x206 Creating custom page template in WordPress

step 5

On Page atribut look for Template option, and choose archive for template attributs.

step5 300x206 Creating custom page template in WordPress

Now, publish your page. I getting result somethink like this.

step6 300x206 Creating custom page template in WordPress

How about getting categories page?, just add code like this

<div id="content">
<!--archive page!-->
<h2>Monthly Archives</h2>
<ul><?php wp_get_archives('type=monthly') ?></ul>
<h2>Categories</h2>
<ul><?php wp_list_cats('sort_column') ?></ul>
</div>

To get blogroll you just add the following template tags.

<?php wp_list_bookmarks(); ?>

This is the final code

<div id="content">
<!--archive page!-->
<h2>Monthly Archives</h2>
<ul><?php wp_get_archives('type=monthly') ?></ul>
<h2>Categories</h2>
<ul><?php wp_list_cats('sort_column') ?></ul>
<ul><?php wp_list_bookmarks(); ?></ul>
</div>

Wrapping up

To create new custom page, you can copy index.php file from your themes folder, remember to add template name on comment at the beginning of page. For more detail about wordpress template page, you can look at the WordPress official site.

Incoming search terms for the article:

Related Posts

Simple Chat Plugin

EWWW Image Optimizer

Twitter Cards PHP 1.1

Create An Effective RSS Feed With mPress WordPress Plugin