Now you can harness the power of Google Search for your Wordpress 404 Error (Not Found) Pages!
If you are blogging over Self Hosted Wordpress Installation, than this post tells you How you can add Google Custom Search to your Wordpress 404 Error Pages?
What is 404 Error (Not Found) Page:
When visitors to your Wordpress Blog / Website lands on a particular page which doesn’t exists at all, they get a 404 Not Found Error. Following are some common reasons when a 404 Not Found Page is displayed:
- Suppose you have a Wordpress Page with URL slug as /abcd and some external site linked to this page with a wrong URL slug /abdc. Now when a visitors lands on this Page, your Wordpress Installation will give a 404 Error to him/her.
- You made a Page Private after Publsihng it, now when a Visitor lands on this Page he/she will get 404 Error.
- There can be some more reasons. You can read more about 404 Not Found Error right here
How to Add Google Custom Search to 404 Not Found Pages?
1. First of all go to Google Web Elements Custom Search Page. Here you will get 3 Options for your Custom Search Engine:
- Automatically Search My Site – Option common to all users.
- Search my Site & Use AdSense for Search – This option is useful for those having a Google AdSense Account.
- Use an Existing Custom Search Engine – If you have created a Custom Search Engine Earlier, than you can simply enter your Custom Search ID (E.g. 012345678901234567890:abcdefghijk)
2. Select Appropriate Option as per your Requirement and copy the JavaScript Code. Now Login to your Wordpress Dashboard, Here go to Appearance >> Editor >> 404 Template (404.php)
3. Here you have to insert the Javascript Code in appropriate location with reference to Screenshot Below:
(If you face any problem while entering the JavaScript Code, please use the Comment Form below)
4. Save the 404.php Template and it’s all done!
The main advantage of Google Custom Search is that, Related Posts/Pages gets displayed just under the Custom Search Box pertaining to the Search Query. This means your visitors will remain only on the 404 Not Found Error Page, but can search anything included in your Wordpress Blog.
Not only this Custom Search Engine be incorporated in Wordpress Blogs, you can easily insert it to any Website by suitable editing the HTML/PHP file.
Related Reading: Inserting AdSense for Search in Wordpress Blog by Removing Wordpress Sidebar, Adding Advertisement Code in between First and Second Post in Wordpress and Adding Advertisement between Wordpress Header and Posts
Related posts:


Oh heck that this does not work on WordPress.com blogs!
Yes! That’s one of the Downside of Wordpress.com Blogs