Dougie Hunt

WordPress Tutorial: Create WordPress Custom 404 Page Without Plugin

WordPress Article


⭐ Updated 14 July 2023

💥 Published 31 December 2020

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 “”

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.


Take part in the discussion

Discussion about WordPress Tutorial: Create WordPress Custom 404 Page Without Plugin article, if you have any questions, comments or thoughts then get leave a reply.

    • Hi Aslam,

      So any URL slug that is not covered by a page, post, media asset, etc, will show the 404.php file.

      So yes, as long as the URL slug /page-not-found/ or anything similar does not exist, then the 404.php will show.

      For example, a 1 page, 1 post WordPress website with 1 images will on ballpark have ~10 set URLs. That includes all the WordPress built-in URLs like /wp-admin/, archives, tags, categories, etc. So any URL slug entered is not part of those will show a 404.php.


WordPress Powered By