How to create a personalized and user-friendly 404 page for WordPress

Source: Internet
Author: User
Keywords Wordpress seo

Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall

As a webmaster, I make mistakes, you make mistakes, we all make mistakes. There are some errors that we can solve with a 404 error page. In general, this page will appear with the following prompts: "404 error: Sorry, the file/page you are looking for does not exist." "Such pages are no help for adding a user experience, so how can you design a friendlier 404 page?"

404 page is not just to point out the problem to the website users, you also need to provide them with a feasible solution.

In WordPress, the default theme of Kubrick, 404 pages are simple and ugly, I believe you will not be too good. This article will teach you to create an excellent 404 pages.

In fact, a good 404 pages in the design is not complex, the purpose is to help site users find the information they want, and continue to browse your site. No more nonsense, let's get started!

Suppose you are a visitor to the site.

Let's say you're a website user and reach 404 pages, it's definitely because you want to find something else, or you can't come here. So there are a few things you absolutely can't do:

First, think that people are likely to click on a link to the site to reach the 404 error page. If so, who is responsible for this? No, it's you.

Second, make the 404 page design style consistent with other pages on the site. Some webmasters like ingenuity, regardless of the user's ability to accept. For example, a webmaster has designed this page to be a common Windows blue screen, but the result is not so good that people are fleeing his site.

Third, if you're going to play a joke, like the blue screen design mentioned above, it's best to make sure everyone accepts it.

Let's design a perfect 404 error page

Ok, now that you know what not to do, you also need to know that users to your site are looking for some specific content, usually they follow a link to come here. Now, as a webmaster you need to provide a variety of ways to help them achieve their goals.

Let's take a look at some of the great 404 instance Pages:

  

On several 404 pages above, conversion rate experts website design I like best, and it also inspired me.

It offers 4 options to help users:

1. Re-search

2, check if there is a link spelling error.

3, in the site map to find.

4, return to the homepage of the website.

The Apple website directly presents the site map to the user, this idea is also very good. You can choose one of them according to your preference.

I suggest you choose conversion rate experts 404 solution, and the design is easy to implement, I will not repeat. Here, I'll add one more: Displays a list of some pages related to the URL URLs that the user has entered. To achieve this, we have to study and analyze this URL address to see if we can find something:

What useful data does a 404 error page provide to people?

Many webmasters will think 404 pages is a dead end. In fact, it can provide a lot of useful data to help you understand the site users ' search intentions. Let's look at the URL address: The domain name/all the characters that follow will prompt you for what the user wants.

Happily, the WordPress system stores this information, and you can find it through the variable $wp_query->query_vars[' name '. The Wp_query class functions are stored in a series of processed, normalized URLs that we can use to build your 404 pages.

First, let's check if there is a page that directly matches the name of the page in the $wp_query->query_vars[' name ' variable.

$s = $wp _query->query_vars[' name '; $s = Preg_replace ("/(. *)-(html|htm|php|asp|aspx) $/", "$", $s); $posts = query_posts (Array (' Post_type ' => ' any ', ' name ' => $s));

If the above statement has no output, you need to use the Str_replace () function to remove the "-" space from the $s string and search again. When we use the $s variable again, we put it outside of the IF statement to check if the previous query had a result.

$s = str_replace ("-", "", $s); if (count ($posts) = = 0) {$posts = query_posts (Array (' Post_type ' => ' any ', ' name ' => $s)}

Now we have some output that is related to the URL that the user entered before, at least, which we think is relevant and displays it as a list in the following statement:

if (count ($posts) > 0) {echo <p>were you looking for <strong>one of the following</strong> posts or pages?</p> "; echo "<ul>"; foreach ($posts as $post) {echo ' <li> '; Echo ' <a href= '. Get_permalink ($post->id). " > $post->post_title. ' </a> '; Echo ' </li> '; echo "</ul>"; }

If you feel that this is too much trouble, you can install plug-in smart 404. It implements the same functionality as described above.

Now a great 404-page is done, and note that if there are too many logs to meet the conditions, you don't have to show them all and pick a part. In addition, the 404 error also provides a useful message to the referrer (user routing): If someone has made a wrong page link to your site, or linked to a page that no longer exists. So the last thing you need to do is:

Avoid the appearance of 404 pages

The advantage of using Google Analytics is that you can view the referrer information so that you can find out where your users are. It can help you to point the URL to the appropriate page, you can also find those with your site made the wrong link to the site, in order to notify the webmaster to correct the link address.

Another good way to track down the site 404 error is to use the Google Webmaster tool. In the "Diagnostics-Crawl Error" menu, Google identifies the possible 404 errors in your site:

  

This article by the most rapid method of breast http://www.hiways.com.cn released, reproduced please indicate the source, thank you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.