March 2010
M T W T F S S
« Dec «-»  
1234567
891011121314
15161718192021
22232425262728
293031  

WordPress – Improve your 404 File Not Found answers (4 of 4)

VN:F [1.4.6_730]
Rating: 5.0/5 (1 vote cast)

In our previous post talking about improving your 404 File Not Found answers in WordPress we have talk about the great plugin Smart 404 to give your viewers more chances. It performs a search of your posts, tags and categories, using keywords from the requested URL and if there’s a match, Smart 404 redirects to that page instead of showing the 404 File Not Found error.At DiceLock Security Blog we prefer to show them the 404 File Not Found, and there is a way to do it…

  Applies to:

WordPress 2.8
Atahualpa 3.2 and other themes
Dagon Design Sitemap Generator 3.16
Smart 404 0.3

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, a Site Map and recommended links in your 404 File Not Found error page, allowing your viewers to search what they are looking for, as in:

404 File Not Found page with Search box, Site Map and recommended links

Smart 404 performs a search of your posts, tags and categories, using keywords from the requested URL. If there’s a match, redirects to that page instead of showing the error. At DiceLock Security Blog we believe that such performance could make our viewers to leave the site.

If a visitor has arrived to our web site for some specific reason that remains in our web site, but it’s not provided through the URL link used by the visitor, if we show him a correct page not related to the reason, maybe the viewer will get out from our web site. So, we prefer to show him that the link through which he has arrived does not exist and we show him the tools that will help him to arrive to the information he looks for.

What we have done is to comment some code lines in smart404.php file.

file: smart404.php
lines: 57-87

	if ( in_array( 'posts', (array)get_option( 'also_search' ) ) ) {
		// Search for posts with exact name, redirect if one found
		$posts = get_posts( array( "name" => $search ) );
/**
//		if ( count( $posts ) == 1 ) {
//			wp_redirect( get_permalink( $posts[0]->ID ), 301 );
//			exit();
//		}
*/
		// Do a general search, redirect if exactly one result
		$posts = get_posts( array( "s" => $search ) );
//		if ( count( $posts ) == 1 ) {
//			wp_redirect( get_permalink( $posts[0]->ID ), 301 );
//			exit();
//		} else if ( count( $posts ) > 1 ) {
			$GLOBALS["__smart404"]["suggestions"] = $posts;
//		}
	}
 
	// Search for pages
	if ( in_array( 'pages', (array)get_option( 'also_search' ) ) ) {
 
		$pages = get_posts( array( "s" => $search, "post_type" => "page" ) );
 
//		if ( !$GLOBALS["__smart404"]["suggestions"] && count( $pages ) == 1 ) {
//			wp_redirect( get_page_uri( $pages[0], 301 ) );
//			exit();
//		} else if ( count ($pages ) > 0 ) {
			$GLOBALS["__smart404"]["suggestions"] = array_merge ( (array)$GLOBALS["__smart404"]["suggestions"], $pages );
//		}
	}
Note: if you view this code through the machine translator, maybe you are viewing a transformed code. Please, view the original English version of the page to see it unaltered.

With this modification your viewers will get something like the following screenshot when they get a 404 File Not Found error when there is a Smart 404 match page:

404 File Not Found page with Search box, Site Map and recommended links

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.

VN:F [1.4.6_730]
Rating: 5.0/5 (1 vote cast)
  • Share/Save/Bookmark

Related posts:

  1. WordPress – Improve your 404 File Not Found answers (3 of 4)
  2. WordPress – Improve your 404 File Not Found answers (1 of 4)
  3. WordPress – Improve your 404 File Not Found answers (2 of 4)
  4. WordPress calling SEO Pager Enhanced Pagination
  5. WordPress Global Translator – Language Flag Space Out

No Comments

You must be logged in to post a comment.

If you want to subscribe to the comments of this information without commenting, enter your email.





Close Me  
Get FREE Random Number Test Windows DLL !
Get FREE Hash Algorithms Windows DLL !