WordPress Tutorial: Create WordPress Custom 404 Page Without Plugin
This is a super simple and quick guide to help you create a WordPress custom 404 page without using a plugin. No plugin required at all!
SEO-Optimised Custom 404 Page for WordPress
This is my own SEO-optimised custom 404 page for WordPress, it doesn’t just give you a custom 404 page but also adds in a full sitemap for your website. So if any pages are missing both human users and bots can find the missing links or alternative links to discover. Good for the user and good for SEO.
Create a WordPress custom 404 page without a plugin
Before you start – You need to have administrative access to your WordPress site and SFTP access. You should also always take a full database and theme file backup before making any changes.
1. Go to your theme folder
2. Create and name a file 404.php
3. Paste the code below into the 404.php file
4. Now tweak to fit your site
5. View on your site by going to “yourdomain.com/error”
WordPress Sitemap Page Code
Below is the WordPress custom 404 page file. This supports Posts, Pages, Custom Post Types and WooCommerce Products. If you don’t want or need Custom Post Types or WooCommerce products support then just delete those loop at the bottom (I’ve annotated each section so should be easy to find).
Answers to your questions
Here are some answers to questions I get asked most about from this article, WordPress Tutorial: Create WordPress Custom 404 Page Without Plugin. I'll try my best to answer any relevant questions that get sent to me when I can. If you have any questions just drop them in the comments below.
What if I already have a 404.php file in my WordPress theme folder?
Ok, you can either edit it or rename your existing 404.php file. I'd just rename it to "_404.php" and then create a new 404.php file and use the custom code on this page. Make sure you tweak to fit the design of your site.