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 (see mine here: http://sugarrae.com/notthere) 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.