How to Create a Custom 404 Page in WordPress (No Plugin)

Every website owner dreads the moment a visitor lands on a dead end. A mistyped URL, a deleted post, or an old bookmark can all send a visitor to the dreaded “404 Not Found” page. The problem is that the default 404 page on most WordPress themes is cold, boring, and completely unhelpful. It gives the visitor no reason to stay. In this guide, you will learn how to create a custom 404 page in WordPress without any plugin, using three simple methods that work for both block themes and classic themes.
What Is a 404 Page and Why Does the Default One Fail?
A 404 page appears when a browser asks your server for a URL that does not exist. The server responds with the HTTP status code 404, which means “not found,” and WordPress shows a template page to explain this to the visitor. So far, so good.
The trouble is that the default 404 page in most themes is just a sad little sentence like “Oops! That page can’t be found.” It offers no search box, no links to popular content, and no path back to your site. Faced with that, most visitors simply close the tab. That is a lost reader, a lost customer, or a lost subscriber, all because of one bad page.
A well-designed custom 404 page changes that story. Instead of a dead end, it becomes a friendly detour. It keeps people on your site, guides them to content they will actually enjoy, and protects your brand image. The best part is that you do not need a plugin or a developer to build one.
What Should a Great Custom 404 Page Include?
Before you build your page, it helps to know what makes a 404 page work. A great custom 404 page is helpful, on-brand, and lightweight. Here are the elements that matter most.
- A friendly, human message. Apologize briefly and explain what happened in plain language. A little humor is fine if it fits your brand, but do not confuse the visitor.
- A search form. Many visitors arrived looking for something specific, so give them a way to find it immediately.
- Links to your most popular posts or pages. This is your chance to rescue the visit by showing your best content.
- A clear button back to the homepage. Make the escape route obvious with a big, visible button.
- Your normal header and footer. Keep the site’s navigation, logo, and styling so the page feels like part of your site, not a server error.
- Nothing heavy. Skip autoplay videos, huge images, and complex animations. A 404 page should load fast and solve the problem quickly.
Notice what is missing from this list: popups, newsletter forms, and ads. A 404 page is not the place to push conversions. Your only goal is to help a lost visitor find their way.
Method 1: Use the Site Editor (Block Themes)
If your theme is a block theme, such as Twenty Twenty-Four or any modern full-site-editing theme, you can create a custom 404 page with zero code. WordPress includes a dedicated 404 template that you can edit just like any other page.
Here is the process. Go to Appearance, then Editor in your WordPress dashboard. Click on Templates in the left sidebar, then find and open the 404 template. If your theme does not include one, click Add New Template and choose 404 from the list.
Now build your page with blocks. Add a Heading block with a friendly message such as “This page wandered off.” Below it, add a Paragraph block with a short explanation and an apology. Then add a Search block so visitors can look for what they need. Add a Buttons block with a button that links to your homepage. Finally, add a Query Loop or Latest Posts block showing three or four of your best posts so the visitor has somewhere interesting to go.
Style it with your brand colors and fonts, keep the layout simple, and save. That is all there is to it. Visit a made-up URL on your site, such as yourdomain.com/this-page-does-not-exist, to preview your new custom 404 page. If you are new to how WordPress templates work, our guide to the WordPress dashboard will help you find your way around the Site Editor.
Method 2: Add a 404.php File (Classic Themes)
If your site uses a classic theme, the Site Editor is not available, and the 404 template is a PHP file called 404.php. Editing your theme files directly is risky because a theme update will wipe out your changes. The safe way is to use a child theme. If you have not set one up yet, follow our tutorial on how to create a WordPress child theme first.
Once your child theme is active, create a new file named 404.php inside the child theme folder. Paste the following code into it. This template uses your theme’s header and footer, shows a friendly message, adds a search form, and includes a homepage button.
<?php
get_header();
?>
<main id="primary" class="site-main">
<section class="error-404 not-found">
<header class="page-header">
<h1 class="page-title">Oops! This page took a wrong turn.</h1>
</header>
<div class="page-content">
<p>The page you are looking for has been moved, deleted, or never existed. Try searching for what you need, or head back to our homepage.</p>
<?php get_search_form(); ?>
<p><a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="button">Back to Homepage</a></p>
<h2>Popular posts you might enjoy</h2>
<ul>
<?php
$popular = new WP_Query( array( 'posts_per_page' => 5 ) );
if ( $popular->have_posts() ) {
while ( $popular->have_posts() ) {
$popular->the_post();
echo '<li><a href="' . esc_url( get_permalink() ) . '">' . esc_html( get_the_title() ) . '</a></li>';
}
wp_reset_postdata();
}
?>
</ul>
</div>
</section>
</main>
<?php
get_footer();
Upload this file to your child theme folder using your hosting file manager or FTP. WordPress will automatically use your child theme’s 404.php instead of the parent theme’s version. Because the code calls get_header and get_footer, the page keeps your normal navigation, logo, and footer, which is exactly what a good 404 page needs.
Want to tweak the design? You can add simple CSS in the Customizer under Additional CSS to style the message, button, and search form with your brand colors. For step by step help with that, see our guide on how to add custom CSS in WordPress.
Method 3: Point .htaccess at a Static Page (Fallback Only)
There is a third method that uses your server’s .htaccess file to redirect 404 errors to a static page. Add this line to the .htaccess file in your site’s root folder, replacing the page name with the URL of the page you want to show.
ErrorDocument 404 /page-not-found/
This method works on Apache servers, but we recommend it only as a fallback, not as your main solution. The problem is that some server setups return a 200 OK status for the error page instead of a real 404 status, which creates SEO problems. The block theme and child theme methods handle the status code correctly by default, so prefer those whenever possible. If you are on a budget host and unsure what server type you are using, check our web hosting guide to understand your options.
SEO Rules for Your Custom 404 Page
A custom 404 page helps visitors, but only if it follows a few important SEO rules. Get these wrong and your helpful page can actually hurt your search rankings.
Always return a real 404 status code
The single most important rule is that missing pages must return the HTTP 404 status code. Never redirect all 404 errors to your homepage. Google calls these “soft 404s” and treats them as a sign that your site is poorly maintained. WordPress handles this correctly out of the box when you use the theme template methods above.
You can verify the status code yourself. Open your terminal and run this command, replacing the URL with one of your own broken URLs.
curl -I https://yoursite.com/a-page-that-does-not-exist
The first line of the output should say “HTTP/2 404”. If it says 200 or 301, something is wrong and needs fixing.
Do not noindex the 404 template
Some guides tell you to add a noindex tag to your 404 page. This is unnecessary. Because missing pages return a 404 status, Google already knows not to index them. Adding noindex to the template is harmless but pointless, and it can cause confusion if you ever reuse that template code elsewhere. Spend that effort on your permalink settings instead. A clean URL structure prevents many 404s in the first place, so read our WordPress permalink structure guide after this.
Monitor 404s and fix broken links
A custom 404 page is a safety net, not a fix. The real solution is finding broken links and repairing them. Open Google Search Console, go to Pages, and look at the “Not found (404)” section. You will see which URLs visitors and search engines are requesting that do not exist.
For each broken URL that used to have content, set up a 301 redirect to the closest matching live page. This passes the old page’s link value to the new one and stops visitors from hitting the error at all. Only leave URLs as 404 when the content is truly gone and there is no good replacement.
For the official technical details on how WordPress builds the 404 template, the Theme Developer Handbook explains the template hierarchy, including which file WordPress loads when a page is not found.
Frequently asked questions
Do I need a plugin to create a custom 404 page in WordPress?
No, you do not. Block themes let you edit the built-in 404 template in the Site Editor with no code, and classic themes only need a small 404.php file in a child theme. A plugin adds weight and another thing to maintain, so the manual methods in this guide are the better choice for most sites.
Will a custom 404 page hurt my SEO?
Not if it returns a real 404 status code, which the methods in this guide do. Google recommends helpful custom 404 pages because they improve user experience. What hurts SEO is redirecting all 404s to the homepage or serving the error page with a 200 status, both of which you should avoid.
How do I test my custom 404 page?
Type a random URL into your browser after your domain name, for example yoursite.com/test-404-page. Your custom design should appear. Then run curl -I on that URL in your terminal and confirm the first line of the response says 404. Test on mobile too, since many lost visitors arrive from phones.
Can I track how often visitors hit my 404 page?
Yes. Google Search Console shows crawl errors under Pages, and most analytics plugins can log 404 hits. Review this list monthly. If the same broken URL keeps appearing, add a 301 redirect so visitors reach real content instead of the error page.
Last updated: October 2026.



