SEO Friendly Titles for WordPress

The standard theme for WordPress doesn’t include very pretty titles. One of the things you can do to optimize readability for users coming in from search engines or bookmarking your page is to clean up your titles. It’s actually pretty easy to do.

We’ll start with the default Krubrick title. This is located in your Header.

<title><?php bloginfo('name'); ?> <?php if (is_single()) { ?>&» Blog Archive <?php } ?><?php wp_title(); ?></title>

A little bland. First off our sitename comes first. Llynix.com doesn’t really convey anything, the juicy information is in the title. In addition with this scheme the home page, 404 page and search pages get a default ‘llynix.com’ as their title.

We need something better. Happily, it doesn’t take much.

  <title>
<?php 
  if (is_single()) { ?>» Blog Archive <?php } 
  if (is_home()) { ?>Home<?php } 
  if (is_404()) { ?>404 Not Found<?php }
  if (is_search()) { ?>Search Results for <?php the_search_query(); }
?>
<?php wp_title(); ?> | <?php bloginfo('name'); ?>
  </title>

Now depending on what we are viewing our page title changes. Also our page title comes first, with the site name after the pipe (|).

Generate Random Password

I was looking for a simple php random password generator. I ended up modifying Jon Haworth’s password generator to come up with this.

function generatepass($length = 8) {
  $password = "";
  $possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKMNPQRSTVWXYZ";
  for($i=0;$i <= $length;$i++) {
    $password .= $possible[mt_rand(0, strlen($possible)-1)];
  }
  return $password;
}

We remove all vowels to avoid words (which will be random and might be bizarre or offensive) and the letter l to avoid confusion. I also added capital letters (I think people are used to case sensitive passwords, we just cut and paste them anyway.)