View Single Post
Old 2007-05-06, 04:43 PM   #1
walrus
Oh no, I'm sweating like Roger Ebert
 
walrus's Avatar
 
Join Date: May 2005
Location: Los Angeles
Posts: 1,773
Send a message via ICQ to walrus Send a message via Yahoo to walrus
Setting Up Your Theme - Part One

For Chasing the Walrus I wanted a very simple, basic theme but I wanted it to be unique and attractive. I chose the moony theme and with a little editing came up with this: Chasing the Walrus.

Note: you don't absolutely need to do any of the things below. Right or wrong, this is simply how I optimize my themes. You can either use what you like or throw it all out a quackery.

Now it's time to start editing the templates. The thing to remember from scratch is that some plug-ins require certain things get added into the script in order to make them work but you can't add them until after you enable the plug-in or your theme wont work. A sort of catch-22.

So I pre-edit the templates a little and then re-edit them as I get to specifics of certain plug-ins.

One of what I feel is a shortcoming of WordPress it that they really don't handle meta-tags well. Specificly, the title, description and keyword tags.

The Title Tag
When I'm on the index page, I want the blog title to appear but when I'm on a category, I want something like this "category name | blog title" and on a page this "page title | blog title". I can blame this on grandmascrotum since she first pointed it out but the damn >> WP likes to add bugs me as well. Especially since it gets added to the front side of the page title and category name. The little hack I found works wonders for taking this out.

You can find the details of the hack if your interested in this thread

I then edit the header.php template file like this:
Code:
<title><?php if (is_home()) {
bloginfo('name');
}else {
wp_title();
echo " | ";
bloginfo('name');
}?></title>
The Description Tag
There are four basic page displays with WordPress
  1. The Index Page
  2. The Single Post Page
  3. The Category Page
  4. basic WP Pages
and if your like me...the tags page

I have yet to find a single solution to having unique descriptions (or keywords for that matter) for all of these pages. WordPress Meta Tag Generator does a pretty good job with this for everything but category pages. With them it uses the same defaults it would use for the index page.

The thing that the plug-in does do that I haven't figured out how to do using template tags is set custom descriptions for WP pages.

For this theme, I'll use a combination of the two....WP template tags and Meta Tag Generator for descriptions. I'll use the Meta Tag Generator for WP pages and template tags for all the rest.

This is how I form my meta-description tag for my header file:
Code:
<meta name="Description" content="<?php if (is_single()) {
echo the_excerpt();}
elseif (is_category()) {
echo category_description();}
else
{
bloginfo('description');}
?>"/>
Notice for a single post, I'm using an excerpt from the post. I don't know if this is a WP2.1.x change or if I'm using excerpt in the header but you must add the excerpt in the optional excerpt field for this to work.

Category uses the category description field you can define when you create the category.

Everything else uses the blog description you set as your tagline.

Since I want different descriptions for pages but I don't want duplicate meta tags, I edit out the following line usually found right before </head>
Code:
<?php wp_head(); ?>
That is the what the meta tag generator will use to add it's meta tags. So obviously, I need a separate header and page templates for this.

I copy my header template and rename it headpage.php. Delete both the meta description and keyword lines and add
Code:
<?php wp_head(); ?>
back in right before </head>

Also, edit the page template file and change
Code:
<?php get_header(); ?>
to
Code:
<?php include (TEMPLATEPATH . '/headpage.php'); ?>
Once I enable Ultimate Tag Warrior, I'll be back to edit this some more.

Keywords
Since I rely heavily on Ultimate Tag Warrior, I wait to set this up until I enable the plug-in as well.

Other pre-install edits:
Let me add that I like to show the full posts on the index and single pages and excerpts on all the rest. To do this I edit category.php, archive.php. Simply find
Code:
<?php the_content() ?>
on these pages and replace it with
Code:
<?php the_excerpt() ?>
Next post, we'll setup the WP options and start enabling plug-ins and adopting the templates for the individual options.
__________________
Naked Girlfriend Porn TGP
free partner account

Last edited by walrus; 2007-05-06 at 04:53 PM.. Reason: its not long enough need to add more
walrus is offline   Reply With Quote