Advertisements

Integrating Smart 404 into the Suffusion WordPress theme

By default, WordPress does very little for a user who lands on a 404 or ‘Not Found’ page. The WordPress Smart 404 plugin can help with this, by attempting to match terms from the URL to published articles. This is something you want especially if you change your categories or tags because your old tag- and category-based URLs will not display anything useful to your visitors. Instead of losing them to a 404 page, show them what they’re looking for — or at least come close.

I use the Suffusion theme here on my blog, and I know it’s a very popular plugin as well, so here’s how to integrate Smart 404 nicely within Suffusion.

Obviously make sure you have both the Suffusion theme and the Smart 404 plugin installed and activated.

Open the theme editor by going to Appearance > Editor and load the 404.php file, change it to include the smart404_suggestions PHP function call as follows:

  
+ <?php
+ if (function_exists('smart404_suggestions')) {
+ echo &quot;<br /><br />Here's some posts that may be close to what you were looking for:";
+ smart404_suggestions();
+ echo "<br /><br />You might also try searching.";
+ }
+ ?&gt;
  </p>
  </div><!--/entry -->

This wraps the smart404_suggestions function nicely in a PHP function_exists call, which will prevent PHP errors if you later decide to uninstall the plugin.

Be aware that if you update your theme at any point, you may have to redo this edit.

Questions, comments, and feedback about this are welcome and appreciated. Thank you!

Advertisements

,