
updated 20100219 because I had to redo things after updating my theme
So we were working on author pages today, and I encountered the first 404 on this blog because sometimes I just can’t type. To say I was not impressed was an understatement. “Something you are looking for is not here.” BORING. So I decided to jazz things up by editing the 404 page. Only problem there is that despite all the blog posts I found about editing 404.php, I couldn’t find a 404.php on my site! So then I went looking for a plug-in, sure that someone must have something to fit the bill. There are several, and I would like to use the smart ones, but they are not yet tested with WP 2.9.1 and I am not ready to go there yet, considering that I need a dictionary to spell PHP and I don’t control the host, so taking a snapshot and restoring it when I bork things is not an option. So I started a hard target search for the wording in the dull 404, and I finally found them within index.php. I guess some of you are thinking “shoulda started there, n00b!” but that is okay, I found it. Here is how to dress it up just a little.
- Using your WordPress admin page, go to Appearance, Editor on the left hand side.
- Select the Main Index Template (index.php)
- Scroll down until you find the section that starts with <?php else : ?>.
- Edit the text between <div class=’entry’> and </div> tags.
You can get creative within that section, changing the text, adding a graphic, even changing the page title (as interpreted by your theme) by replacing the text between the legend tags. Since most of our 404s come from me moving stuff around, I added links to the most popular content from the old site.
Here is what we have on RetroHack so far.
<?php else : ?>
<div class="post">
<fieldset>
<br/>
<br/>
<div class=’entry’>
<image src="http://retrohack.com/_retroh_wp_root/wp-content/uploads/2010/01/renAndStimpy.jpg" style="float:left; margin:10px;" />
<br/><legend class=’title’>Ohs Noes!</legend> <br/>I don’t understand it. There is no place for it to hide, but it’s just not in there! <br/> <br/> <br/>
Sorry, it looks like we dropped the ball and threw you a 404! <br/> <br/>
Please try the search box above, or the categories and tags on the sidebar.
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
Or, you can take a look at some of the links below, which are the most popular posts here from the deprecated Networkplumbing.org site.
<li><a href="http://retrohack.com/error-0x80074e46-while-installing-an-isa-2006-replica/">error 0×80074e46 while installing an ISA 2006 replica</a> </li> <li><a href="http://retrohack.com/enabling-ipsec-vpn-connections-to-isa-2006/">Enabling IPSec VPN connections to ISA 2006</a> </li> <li><a href="http://retrohack.com/creating-dhcp-reservations-at-the-command-line/">Creating DHCP reservations at the command line</a> </li> <li><a href="http://retrohack.com/creating-dns-records-at-the-command-line/">Creating DNS records at the command line</a> </li> <li><a href="http://retrohack.com/enabling-telnet-links-in-internet-explorer-7/">Enabling telnet links in Internet Explorer 7</a> </li> <li><a href="http://retrohack.com/make-bginfo-a-standard-part-of-your-windows-server-deployments/">Make bginfo a standard part of your Windows server deployments</a> </li> <li><a href="http://retrohack.com/establishing-a-trust-across-a-firewall/">Establishing a trust across a firewall</a> </li> <li><a href="http://retrohack.com/syn-syn-ack-rst-rst-wtf/">SYN, SYN ACK,…RST. RST? WTF?</a> </li> <li><a href="http://retrohack.com/isa-server-2006-certificate-autoenrollment-with-online-microsoft-ca/">ISA Server 2006 certificate autoenrollment with online Microsoft CA</a> </li> <li><a href="http://retrohack.com/enabling-nlb-on-isa-2006/">Enabling NLB on ISA 2006</a></li> <li><a href="http://retrohack.com/traceroute-response-codes/">traceroute response codes</a></li> <li><a href="http://retrohack.com/importing-a-certificate-with-keys-into-isa-2006/">Importing a certificate with keys into ISA 2006</a></li> <li><a href="http://retrohack.com/isa-2006-makes-firefox-cry/">ISA 2006 makes Firefox cry</a></li> <li><a href="http://retrohack.com/creating-an-iso-in-esx-from-a-mounted-cddvd/">Creating an ISO in ESX from a mounted CD/DVD</a></li> <li><a href="http://retrohack.com/pixasa-logging-levels/">PIX/ASA logging levels</a></li> </ol>
</div></fieldset>
</div><?php endif; ?>
We’re also now using the Smart 404 plugin, which does a great job of looking at URLs, referrers, typos, and such and landing users at a likely destination. That, I like!
I’m sure that I will figure out more of PHP’s syntax so I can dress up that 404 better, but this should be enough to get started with. What about you?
Have any unique or cool 404 pages to share, or another/better way to do this? Leave a comment to share the knowledge, or if this post helped you too, leave a comment with a URL so we can see the results!
You might also enjoy:





