Wednesday, January 23, 2013

Wordpress - Creating a template

In my previous post we saw on how to create a custom child theme. In this post we'll extend our understanding to creating templates in wordpress.

When working with wordpress to create custom sites, more often than not you will encounter the need to create customized pages. Thanks to the extensibility of wordpress, this is very simple to achieve. Below are the simple steps to do this.

  • Navigate to the theme directory in your wordpress installation. [e.g. "/wp-content/themes/twentyten"]
  • Create a new file called, "my_template.php" (or whatever name you choose)
  • In the new file add the code below. 

Template Name: My Template

<?php get_header(); ?>
Welcome to my template!!
<?php get_footer(); ?>

Here, "Template Name" refers to the name that your template will be called. This will be shown to you in the admin panel while creating new pages.
Next we get the header and the footer for the site with some custom coding in between, where in you can place your HTMLs.
Simple enough and you are done. Now all you have to do is create a new page in wordpress and assign your template to it and you are ready to go!!

In the next post we will see how to create plugins in your wordpress installation.

No comments :