WordPress – Improve your 404 File Not Found answers (3 of 4)
In our previous posts of this collection we have shown how to provide your viewers with a tool to let them stay in your WordPress website when they get a 404 File Not Found error through a Search form and a Site Map. In this post we are going to perform a new step forward, we will provide them with another tool, Smart 404, to give them more chances…
| Applies to:
WordPress 2.8 |
These customizations are provided “AS IS” without warranty of any kind and DiceLock Security disclaims all warranties, EITHER EXPRESS OR IMPLIED INCLUDING THOSE OF MERCHANTABILITY, NONINFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY, OR FITNESS FOR A PARTICULAR PURPOSE.
Upgrading or reinstalling the customized source code (package, plugin, component, …) may remove the customizations performed. |
In our previous posts we have shown how to add a Search box and a Site Map link in your 404 File Not Found error page, allowing your viewers to search what they are looking for, as in:
There is another tool that improves you web site, this is Smart 404. It allows to perform a search of your posts, tags and categories, using keywords from the requested URL. If there’s a match, redirect to that page instead of showing the error. If there’s more than one match, the 404 File Not Found page can use some template tags to provide a list of suggestions to the viewers.
One way to allow your 404 File Not Found viewers go further your web site is to display a list of suggestions to the viewers.
As in previous posts, you can put in your 404 File not Found page, maybe in your 404.php or in index.php (located under atahualpa folder) in Atahualpa theme as in the exemple calls to Smart 404 plugin. The 404 File Not Found page would be in Atahualpa theme:
<?php // END of: If there are any posts // If there are no posts: else : ?> <h2><?php _e('Not Found','atahualpa'); ?></h2> <table width="100%"> <tr> <td colspan="2"> <br /><p><?php _e("Sorry, but you are looking for something that it's not found. ","atahualpa"); ?></p><br /> </td> </tr> <tr> <td colspan="2"> <b>Site Map</b><br /><br /> You can access the <a href="site-map/">Site Map</a> in order to view all blog content, maybe you can access the information you are looking for from there !!!<br /><br /> </td> </tr> <tr> <td colspan="2"> <?php if (smart404_has_suggestions()) : ?> <b>Suggestions</b><br /><br /> We have found that maybe there is something related to what you are looking for at the following links, you can try them:<br /><br /> <?php smart404_suggestions(); ?> <?php endif; ?> <?php if (smart404_loop()) : ?> <p>or, try any of these posts:</p> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; ?> <?php endif; ?> </td> </tr> <tr> <td colspan="2"> <br /><br /><b>Site search</b><br /><br /> Or you can use our search form to find the proper information you are looking for ...<br /><br /> </td> </tr> <tr> <td width="50%"> <?php get_search_form(); ?><br /><br /> </td> <td> </td> </tr> </table> <?php endif; ?> <?php get_footer(); ?>
Where the inserted code is:
<tr> <td colspan="2"> <?php if (smart404_has_suggestions()) : ?> <b>Suggestions</b><br /><br /> We have found that maybe there is something related to what you are looking for at the following links, you can try them:<br /><br /> <?php smart404_suggestions(); ?> <?php endif; ?> <?php if (smart404_loop()) : ?> <p>or, try any of these posts:</p> <?php while (have_posts()) : the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; ?> <?php endif; ?> </td> </tr>
With this modification your viewers will get something like the following screenshot when they get a 404 File Not Found error:
As we have commented in our previous posts, in this way, your viewers will get in front of their eyes tools that will make them to stay in your site.










































