Need a WordPress website this weekend? Start here...

Switching WordPress Blog URL to subdomain

(Reading time: 2 – 4 minutes)

So you want to switch your blog to a subdomain, and you want everything to work.

Yeah, right!

Ok, it’s not that difficult, but it is a little bit picky. You will need to pay attention and be careful.

As usual, the first thing to do is back up everything:

  1. Database backup, and
  2. WordPress installation backup.

We want to use the subdomain http://blog.mydomain.com/ mapped to http://mydomain.com/wpblog. The benefits of this are:

  1. Looks more professional.
  2. Helps shroud the site structure from bonehead script kiddies.

A real professional, thoroughly malicious hacker probably won’t be fooled. Then again, the pro isn’t likely going to smash your site either by accident or for fun. He wants to use your bandwidth anonymously, not get you kicked off the host.

The next thing to do is put on some decent music. At the moment, I’m in the mood for Norman Fairbanks “7 Days Microsleep,” billed as the first purely Tenori-On album released. If you aren’t familiar with the Tenori-On, Little Boots will demonstrate it’s capability on a cover of Hot Chip’s “Ready for the Floor.” You can’t buy this album. You have to download it from One American Second. Make sure to leave a tip!

Now get a notebook. A paper notebook, with pen or pencil. You can always punch your notes into your computer later; this is one of the few times I believe paper and pen are best. As you follow the procedure, write down exactly what you do and how you do it. This way if you have to backtrack, it will be much easier.

Log on to your hosting provider. I’m at Bluehost; I’ll be using their cPanel interface.

  1. Open your FTP client.
  2. Create subdirecory (wpblog); move all WordPress files there
  3. Log in to cPanel.
  4. Create subdomain using cPanel tools: blog.mydomain.com -> mydomain.com/wpblog
  5. Go into phpmyadmin, find the database, click on that, click on wp_options table, click on “Browse”, fix the paths field: mydomain.com -> blog.mydomain.com
  6. Go into wp-admin page, fix paths: mydomain.com -> blog.mydomain.com
  7. Optional Add the redirect using cPanel: mydomain.com -> blog.mydomain.com

That’s the fast and dirty, and it worked fine for me.

If you have enough traffic that you want to preserve your SERPs, you will need to add appropriate 301 redirections. I recommend using John Godley’s Redirection plugin for this chore, which makes it much easier.

Let me know if you have any trouble with this procedure. If the mere thought of this gives you the willies, drop me a line and we’ll talk about it.

How To Set Up Your Thesis Theme 404 Page To Drive SEO Results

(Reading time: 3 – 5 minutes)

When a reader browses into your blog by requesting a page that doesn’t exist, the web server delivers a 404 error, and may deliver a custom page as well. WordPress is configured to allow such custom pages to be served to the user in lieu of the page or post that the user was requesting. However, the default page is not very useful for keeping reader’s attention.

A better way to deliver 404 errors is to give the user a page full of interesting, compelling content to help her decide to stick around and read what you have to say.

There are several ways to do this, and some of them depend on the theme you are using.

Customizing your Thesis theme

Setting up your custom 404 page in Thesis Theme is easy. I used Sugar Rae’s Thesis 404 tutorial, and it worked perfectly… once I remembered about cutting and pasting…


>>>WARNING: If you cut and paste code from a web page, do NOT be surprised when it doesn’t work. I’ve discussed this before. If you cut and paste Sugar Rae’s code, it won’t work and you will get the problem shown in the screen capture to the right: the “smart” quotes do not paste correctly for source code. They need to be “dumb” quotes.

Bad (red) quotes from cut and paste

Bad (red) quotes from cut and paste

The green boxes show single quotes that I’ve corrected, the red boxes show the quotes that were pasted in. Make sure you get it right. You might want to review my Key Technique For Learning HTML and PHP as well.

You should implement Sugar Rae’s bare bones implementation first, then test it to make sure it’s working correctly. Once it’s working correctly, make sure you understand how it works using the Thesis hook system.

Building Smarter 404 pages

Wouldn’t it be great if your 404 page returned some related pages, instead of a dumb error, or some stupid snide remark?

I think so too, and so did Michael Tyson, who wrote the Smart 404 plugin. I can’t say it any better than he can, so in his words:

When a page cannot be found, Smart 404 will use the current URL to attempt to find a matching page, and redirect to it automatically. Smart 404 also supplies template tags which provide a list of suggestions, for use on a 404.php template page if a matching post can’t be immediately discovered.

This sounded like a great idea, so I embedded his suggested code into Sugar Rae’s Thesis custom hook shown above, and with a minimum of effort I have a new, customized “smart” 404 error page! Here’s my finished implementation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Custom 404 Hooks */
function custom_thesis_404_title() {
?>
We're checking it out for you.
<?php
}
 
remove_action('thesis_hook_404_title', 'thesis_404_title');
add_action('thesis_hook_404_title', 'custom_thesis_404_title');
 
function custom_thesis_404_content() {
?>
<p>Can't find what you want?</p>
 
<?php if (smart404_loop()) : ?>
<p>Try one of these posts instead:</p>
<?php while (have_posts()) : the_post(); ?>
<h4><a href="<?php the_permalink() ?>"
  rel="bookmark"
title="<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h4>
  <small><?php the_excerpt(); ?></small>
<?php endwhile; ?>
<?php endif; ?>
 
<?php
}
 
remove_action('thesis_hook_404_content', 'thesis_404_content');
add_action('thesis_hook_404_content', 'custom_thesis_404_content');

Go ahead and test it out. Use a dumb URL like http://website-in-a-weekend.net/foo-bar-header-twit-plugin. Nice, eh?

And remember, if you don’t surf, you’re not allowed to use the word “gnarly.”