nyssabrowndesign

Welcome to my redesign - okay, I'm kidding. This is a temporary "interval" theme. It didn't take too long. I am still redesigning but mean while, I'm putting this up. Why? I have some other projects I need to get stuck into, which reduces my time a little. I'd also like to contemplate my redesign a bit as I'm currently unsure about its direction. To understand more and the reasons behind my interval theme, read I haven't redesigned, but stay tuned!

WordPress template files for pages, part 1

One thing I have come to do more often is using a template file to create my pages. It makes setting up my pages slightly longer, but it’s more than worth it. Why? What are the benefits? I’m sure there are quite a few benefits, but there is only one I truly care about: formatting.

When using the usual way to create pages (Write > Write Page), it’s often I may find that saving plays with my formatting a fair bit (eg: changing a div class to a p class), which 9 times out of 10 has undesirable effects (unclosed tags, for example, which can lead to invalid XHTML, which then in turn can lead to cross-browser compatibility problems - IE6 especially). While it’s usually nothing major, I do like to make sure my website and it’s pages are as valid as they could possibly be.

So, what are template files, anyway? Well, anytime you download a theme, all those files in the root folder that end with .php (archive.php for example) are templates files. I will let WordPress explain it:

Templates are the files which control how your WordPress site will be displayed on the Web. These files draw information from your WordPress MySQL database and generate the HTML code which is sent to the web browser. Through its powerful Theme system, WordPress allows you to define as few or as many Templates as you like all under one Theme. Each of these Template files can be configured for use under specific situations.

Let’s just say these template files are quite powerful!

Which brings me to the pages on my site that use these template files, that aren’t “default”:

A couple there, and plans to change my Client Testimonials page too, since the formatting isn’t really ideal for me and I’ll get a more desirable result if I use a template file. Also, when having a look at the Credits page, you may notice it’s more or less just a “blogroll” or “bookmarks” system, which brings me to the next benefit of using template files for pages.

When using template files, the added benefit besides (X)HTML formatting is php. While you can use plugins to help with using php in pages, why do that when you can just use a template file? My Credits page looks something like the following:

<p>Listed here is everything I’ve used to create the current design you see here today, including plugins I’m using.</p>
<ul><?php wp_list_bookmarks(’categorize=0&category=22&show_description=1
&title_li=&between=<br />&orderby=id&after=</li><br />’); ?></ul>
<p>WordPress Plugins being used are:</p>
<ul><?php wp_list_bookmarks(’categorize=0&category=23&show_description=1
&title_li=&between=<br />&orderby=id&after=</li><br />’); ?></ul>

Of course, there are other advantages, like having complete control over the (X)HTML. In the next article, I will talk about how to setup a template file, dissect one of my own and how to use them.

2 Responses to “WordPress template files for pages, part 1”

  1. } Mike Robinson wrote }

    Great post, Nyssa :D

    This was something I was planning to do for my projects page, and any others that I add in future. Looking forward to the next part ;)

    # August 27th, 2007 at 3:07 pm
  2. [...] previous post, WordPress template files for pages, part 1, was all about why I use template files for most of my pages. The main reason is formatting, but of [...]

    # August 30th, 2007 at 9:35 pm

Leave a Reply