Categories
Code

404 Page for WordPress with Suggestions

If a visitor mistypes a URL to your WordPress blog or clicks on a link that does not exists, you can show them a more helpful 404 error page that will have suggestions pointing to related articles that they can check out on your WordPress site. Internally, it runs a search using the 404 page URL as the query parameter.

Save this file as 404.php and place it in your WordPress theme folder.



404 Error - Page not found

query_vars['is_search'] = true; $s = str_replace("-", " ", $wp_query->query_vars['name']); $loop = new WP_Query('post_type=any&s=' . $s); ?> have_posts()): ?>

We tried finding the matching pages from our website. Here're some suggestions:

    have_posts()): $loop->the_post(); ?>