Whoops! Page Not Found
It happens that people do small mistakes on your site that ends up in a ordinary “Whoops! Page Not Found.” message. But that standard “404-Error” page looks extremely odd and boring! Let’s give it some affability and present your visitors a more useful message than just “NOT FOUND”
You like the idea? OK, here we go:
We only need to copy and edit the existing 404.php file:
As usual, we don’t want to modify the original files from ClassiPress. So the first thing we do is upload a copy of the original /themes/classipress/404.php file to your /themes/your-child-theme/ folder. Now we start to edit our copy. You can do it local our use your build in WordPress editor in your admin area => Appearance.
Open that 404.php file and find this part of code, starting around line 22:
<h1 class="single dotted"><?php _e( 'Whoops! Page Not Found.', APP_TD ); ?></h1>
<p><?php _e( 'The page or ad listing you are trying to reach no longer exists or has expired.', APP_TD ); ?></p>
Replace the above code with this:
<h1 class="single dotted">Whoops! Something went baaaadly wrong!</h1>
<a href="<?php echo home_url(); ?>" title="OK, let's start from the beginning"><img src= "<?php echo get_stylesheet_directory_uri() ?>/images/notfound.png"></a>
<p><h2>We're sorry, but the page you requested can't be found!</h2></p>
<p>Have you checked your address bar? Maybe there is just a small typo in the URL.</p>
<p>If there isn't, may I kindly ask you to <?php echo '<a href="mailto:'.get_bloginfo('admin_email').'">inform me about this error</a>'; ?>, so I can fix it.</p>
<p><h1>Thank's a bunch for your help!</h1></p>
Finally we only need to upload an image with the name notfound.png to our /themes/your-child-theme/ folder. If you like this smiley from our sample, just comment below so i can send it to you.
So what does the above code do?
- We changed the title message
- We call an image from your /your-child-theme/images/ folder with the name notfound.png
- A click on this image brings the visitor back to the home page
- We explain what may have happened
- We offer a mailto link that sends an email to the site admin (it calls the email address that you have set in WordPress => Settings => General)
- We say thank you 😉
The result will be something like this:
Enjoy your new 404.page and rate this tutorial if it was useful for you.