Website’s traffic is the most important and valuable thing for all webmasters. We work hard to get visitors and every visitor is really valuable for us. In case they land on a page or post which doesn’t exist on our website. There are chances we lose our hard earned visitor and they also do not get good impression about our website. Unlike static HTML sites which produce server’s 404 error page. In modern WordPress websites we direct users to 404 error page to help them find what they are looking for.
To help visitors, so they do not feel lost when they try to enter a page which doesn’t exist on site. We take help of 404 error pages. There are several reasons why people can land on a 404 page. For example someone linked your page on their site but they typed wrong destination in url. So the 404 error page template help visitors find what they are looking for.
How to add or customize the 404 error page in WordPress
As you have seen different servers handle 404 error pages with their own custom templates. Which do not provide them enough or helpful information to find what they are looking for.
Add 404 Error Page in WordPress
First of all check which theme is active in your WordPress by going to wp-admin >> Appearance. Now sign in to FTP or access WordPress files via file manager. Go to wp-content/ directory themes/ directory then enter in the directory of your active theme.
Once you are inside the directory of active theme. Download page.php and rename that to 404.php filename. Now make changes you want in 404.php file and upload that in your theme. Your site have custom 404 Page template for WordPress.
Note: If your theme already have 404 page you can customize it.
Customize 404 Error Page WordPress
If your WordPress theme already have 404 error page. But you want to make certain changes into that template. In that case you need to customize or edit the existing 404 error page.
Note: In case you want to update your theme again and again. In that case copy 404.php into your child theme directory. So you do not lose your work on theme updates.
- First of all find out the theme name which is active simply go to wp-admin >> Appearance and note the name of theme.
- Once you know theme name you can access theme files in 3 ways.
- Access file via Hosting Panel File Manager
- You can use FTP to access your site files
- Also wp-admin >> Appearance >> Editor let you edit theme files as well.
- Edit 404 page and add the information you want. Update file and you are done.
That is enough to customize the 404 error page as per your requirements.
Redirect 404 to Static Page
To redirect users from 404 page to static page let’s say home page. You can edit 404 page template and add the following code.
<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: ".get_bloginfo('url')."/page-title/"); exit(); ?>
If you want user to redirect to any other page which isn’t home page. Just replace page-title/ to the slug of page you want.
There are many plugins available which can help you track the 404 visitors and redirection. For example Custom 404 Pro .
I hope this is helpful post for you if you have any questions you can post comment below.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?