Article / Blog

Quick WordPress Theme Tips

1. Page Titles

Instead of using the standard:

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

You can add a little more to it, so that you have control of the title of the home, search, author, single pages etc.

<title>
<?php if ( is_home() ) { ?><?php bloginfo('name'); ?> &raquo; <?php bloginfo('description'); ?><?php } ?>
<?php if ( is_search() ) { ?><?php bloginfo('name'); ?> &raquo; Search Results<?php } ?>
<?php if ( is_author() ) { ?><?php bloginfo('name'); ?> &raquo; Author Archives<?php } ?>
<?php if ( is_single() ) { ?><?php wp_title(''); ?> &raquo; <?php bloginfo('name'); ?><?php } ?>
<?php if ( is_page() ) { ?><?php bloginfo('name'); ?> &raquo; <?php wp_title(''); ?><?php } ?>
<?php if ( is_category() ) { ?><?php bloginfo('name'); ?> &raquo; Archive &raquo; <?php single_cat_title(); ?><?php } ?>
<?php if ( is_month() ) { ?><?php bloginfo('name'); ?> &raquo; Archive &raquo; <?php the_time('F'); ?><?php } ?>
<?php if (function_exists('is_tag')) { if ( is_tag() ) { ?><?php bloginfo('name'); ?> &raquo; Tag Archive &raquo; <?php  single_tag_title("", true); } } ?>
</title>

2. Body Classes

To gain more control over the styling of your pages, you can set it up so that the title of each post is applied as a class to the body element.

<body class="<?php echo $post->post_name; ?>">

You can take this even further by adding classes for the type of page (ie. 404, search, archive etc.), the operating system and browser that the visitor is using.

For more information on this check the Sandbox and Thematic themes.

3. Dynamic Copyright

Often I see website footers that say “Copyright 2008″.

To make it so the year is automatically updated for you, just add:

Copyright &copy; <?php echo date("Y"); ?> <?php bloginfo('name'); ?>.

2 Comments

Show/Hide
  1. 3:32 am - Mar 21st, 09

    Thanks for sharing this info. By the way, I often see website footers that say Copyright 2005 or even 2000… hehehe :) Cheers.

  2. Matt
    10:24 am - Mar 21st, 09

    Yes, I have seen those as well.

Post a Comment

Why not join the conversation? Don't have an avatar? You might want to consider getting one.

Tasty Web Bits

To celebrate the launch of the Digg iPhone App, Digg is giving away 14 custom iPads.

Smoking Apples is giving away a couple of licenses for AppZapper 2.

AppZapper 2 has been released, and is sporting a brand new, very delicious looking UI.

Envato’s new iPhone News and App Review site, iPhone.AppStorm has launched.

Win a copy of 1Password via Mac.Appstorm.

Very cool tutorial on creating a Textured Grungy 3D Type Design over at Blog.SpoonGraphics.