Rae Hoffman

Thesis Tutorial - Customizing the 404 Page

by Rae Hoffman on January 14, 2009 | Blogging It

404 Error

If you're new here, you may want to subscribe to my feed or subscribe to me on Twitter, which is updated on a more frequent - and more meaningless - basis.

A few weeks ago, I published a Thesis theme tutorial that showed you how to do advanced ad targeting. The tutorial showed you how to assign ads to be different based on the category the posts were filed in, as well as change them on a post by post basis.

While “You 404′d it. Gnarly, dude.” is a semi-custom page since it does keep with your theme and design, you may want to give it a little bit of your own personality and wording to make it truly “custom”. Below, I’ll show you how to do it.

Step 1: Open your custom_functions.php file (thesis > custom > custom_functions.php) in your favorite editor

Step 2: Underneath the example code already in the file, place the following code (this code assumes your blog is in the root):

/* Custom 404 Hooks */
function custom_thesis_404_title() {
?>
YOUR 404 PAGE HEADING HERE
<?
}

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>WHATEVER YOU WANT YOUR 404 PAGE TO SAY HERE</p>
<?
}

remove_action(’thesis_hook_404_content’, ’thesis_404_content’);
add_action(’thesis_hook_404_content’, ’custom_thesis_404_content’);

The /* Custom 404 Hooks */ is a label for the code below so you know what it is at a single glance and is not part of the actual “code”. The word “function” tells Thesis you want it to do something. The custom_thesis_404_title is what I decided to name that function.

You’ll notice this code has two functions. One controls the 404 page heading (custom_thesis_404_title) and one controls the 404 page content (custom_thesis_404_content).

The code is pretty self-explanatory on how to edit. The two lines underneath each function tell Thesis to remove it’s default thesis_404_title and thesis_404_content and replace each with the custom versions. (See hooks for dummies for a more detailed explanation of how this hook “works.”)

Custom 404 pages are your only chance to turn a lost visitor into a site user, so you want to make sure you serve up something that makes a good first impression. If you need some 404 inspiration, check out these 100 awesome and creative 404 error pages.

Subscribe to the Sugarrae feed | Follow Sugarrae on Twitter

Related Posts

Sugarrae runs on the Thesis WordPress Theme

Thesis WordPress theme

If you’re a blogger looking for a professional presence but don’t understand a lot of PHP, Thesis will give a ton of functionality that you wouldn’t be able to obtain otherwise with a simple control panel. With the incredible customization possibilities via Thesis hooks, you can easily make your blog stand out from the crowd.

Thesis allows bloggers to make more professional customizations than they may have ever deemed possible due to lack of coding knowledge. The theme allows me to run Sugarrae more professionally, with a focus on monetization that is more targeted than I’ve ever been able to achieve with a theme before. You can find out more about Thesis below:

{ 1 trackback }

SearchCap: The Day In Search, January 14, 2009
January 14, 2009 at 5:58 pm

{ 21 comments… read them below or add one }

1 HowToMakeMyBlog.com January 14, 2009 at 10:04 am

I guess there is now nothing else for me to do then to make a custom Thesis 404 page as this article shows it to be pretty simple… thanks for the guide!

2 kristen January 14, 2009 at 3:03 pm

Since you’re always dooling out these cool thesis tutorials I would love to know how you add that spiffy blue thesis promotion box to your post!

Rae Hoffman 3 Rae Hoffman January 14, 2009 at 3:04 pm

Actually, that little tidbit (how to make the blue box) is coming out as an exclusive tutorial for my newsletter subscribers at the end of this month - so subscribe now so you don’t miss it :)

4 Lexi January 14, 2009 at 3:49 pm

Thanks, this is just what I was looking for. The custom 404 message of Thesis does not sound like me at all and does not make a good impression. Rae, you’re the only one standing between me and regretting buying Thesis. Thank you!

PS Can’t wait for your newsletter

5 kristarella January 15, 2009 at 10:04 pm

Short, sweet and effective. Very good to point people on the forums to. Lovely!

6 Anna January 16, 2009 at 3:48 am

Nice! I just recently discovered Thesis and absolutely love it. Thanks for the tips!

7 Leesa Barnes January 16, 2009 at 11:16 am

No wonder you’re one of the Top 10 Most Influential Women in Social Media in Canada. With tutorials like this, it’s not a mystery. I’m using Thesis (which I adore) so I’m going to edit the 404 page based on your tips.

8 Andrew Slack January 16, 2009 at 3:34 pm

Great post, very informative and well layed out, thanks alot :)

9 Teli January 16, 2009 at 5:15 pm

This is a great tutorial Rae, but I’m curious why Thesis simply doesn’t have a custom 404 page layout which would allow the user to create the 404 title/content from within the WP admin panel, or does it?

Hmmm, in any event, this tutorial has inspired me to create a quick little tutorial for theme authors so they can do exactly that.

10 Tara Joyce January 19, 2009 at 6:41 pm

Thanks so much for this tutorial. But a question: if my blog does not sit in the root of my site, how do I need to tweak this code? Or can I not use it at all?

filontheroad 11 filontheroad January 20, 2009 at 9:19 pm

Hello Rae,

I apllied the code to change the 404 page on one of my sites, but i still get the ususal 404 “You 404’d it. Gnarly, dude.”-page when entering a not existing page. What did i do wrong?

Best regards,
Fil

12 Neticule January 23, 2009 at 12:55 am

Good tutorial, I always knew my 404 page should be something a bit more descriptive. This will help, now to decide what to do with it!

13 mike January 24, 2009 at 12:51 pm

I agree with Phil, I am having a little trouble getting the new 404 to show up? I posted the text and ran with it, I’ll just have to get tinkering

14 kyle January 31, 2009 at 12:23 am

@filontheroad: check the quotes in the copied paste. I noticed when I pasted into Textmate it maintained the ‘fancy’ quotes, and wasn’t working. When I changed the quotes to standard quotes, it worked fine.

15 filontheroad February 1, 2009 at 5:58 pm

@kyle thanks for helping out. I had the same problem while copying the code to textmate with the quotes. ;-)

16 Grand Rapids Web Design February 4, 2009 at 11:17 am

I recently designed a site that I used custom 404 pages. I’ve never done it before I read you post and I like the way it works. Thanks!

17 Jo March 23, 2009 at 4:11 am

Hi Rae, I’ve seen some very creative 404 pages that used images to add humor or interest. But I have Googled it to death and cannot find how to do more than change the text. Do you have any experience with this? Thanks.

18 Emplic April 6, 2009 at 10:16 am

Thanks for this Rae — not using Thesis (I know, I know…) but will implement with the theme I have in place. The idea behind customizing the 404 page isn’t new, but your tutorial and perspective is helpful.

The list of “100 awesome and creative” 404 pages is actually the jewel of this post. Favourites have to be the ‘Truth Behind 404′ and the ‘Whining, Nerd Twins’. Damn, wish I could say that I don’t identify with the latter…

Anyway, thanks again. (Chuck Norris, how could I not mention Chuck Norris!?!?)

19 Torley April 12, 2009 at 9:06 am

The “fancy” quotes weirdness also gave me a problem — thx for the above pointers, after I did a find-and-replace I was good to go!

20 Torley April 12, 2009 at 9:06 am

OMG check out what I did, yayzerama Sugarrae!

» http://torley.com/404

21 Dansko May 27, 2009 at 6:42 am

What I generally do it redirect user to main page of the site and add a 404 message at the top.

Leave a Comment

Want to add a picture and social profile links to your comments here on Sugarrae.com? All you gotta do is be be logged in when commenting after filling out your user profile.

Not registered at Sugarrae? Register now!

Please note that by clicking submit, you agree to abide by the comment policy.