Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Create a Custom 404 Page in a WordPress Child Theme

Learn where 404.php or templates/404.html belongs in a WordPress child theme, how to preserve the parent shell, style the page, and verify a real 404 response.
Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In a classic PHP theme, create a file named 404.php in the root of the active child-theme directory. WordPress uses that file for requests it cannot match and falls back to index.php if it is unavailable. Because a child-theme file with the same name overrides the parent file, you can replace the parent 404 safely while retaining the rest of the theme. Block themes use templates/404.html instead.

First identify the theme architecture

The correct filename and editing method depend on whether the active parent theme is classic or block-based. Classic themes assemble pages with PHP templates and functions such as get_header(); block themes use HTML templates containing block comments and template-part references. Choosing the wrong method is the most common reason a custom 404 appears to do nothing.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Theme architecture 404 template location in the child theme How the page is assembled
Classic PHP theme 404.php in the child-theme root PHP markup between get_header() and get_footer()
Block theme templates/404.html Block markup with header and footer template parts

You can inspect the active theme under Appearance → Themes. If the Site Editor and template editing tools are prominent and the theme is described as a block theme, use the HTML-template route. If the theme contains PHP template files such as single.php, page.php, and 404.php, treat it as a classic theme. The parent theme’s own documentation or file list can confirm the architecture when the label is unclear.

Make sure the child theme is active

A child-template override works only when the child theme is installed, associated with the correct parent, and activated. In the child theme’s style.css, the header must include a theme name and a Template value that exactly matches the parent theme’s directory name, including capitalization where the file system requires it.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
/*
Theme Name: Game Site Child
Template: parent-theme-directory
*/

Replace parent-theme-directory with the parent folder’s actual slug; it is not necessarily the display name shown in the Themes screen. Put the child folder in wp-content/themes/, activate it at Appearance → Themes, and verify that the expected child theme is marked active. Do not edit the parent folder directly: an update can overwrite those changes.

Before changing the 404 template, take a backup or commit the child-theme files. If a deployment process builds themes from source control, make the change there rather than only in the production file editor. This keeps the override reproducible when the site is moved or restored.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create the classic-theme 404.php file

Create 404.php directly inside the active child-theme directory, alongside style.css and (if present) functions.php. Do not put it in a subdirectory. WordPress’s template hierarchy checks 404.php for a not-found request before falling back to index.php. A child file with that name takes precedence over the parent file.

A safe starting point is the parent theme’s existing 404 template. Copy its structural wrappers, hooks, classes, and accessibility attributes into the child file, then change only the content you need. If the parent has no 404 template, this minimal version preserves the shared site shell:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
<?php
/**
 * The template for displaying 404 pages (Not Found)
 */
get_header();
?>
<main id='primary' class='site-main'>
  <h1><?php esc_html_e( 'Page not found', 'game-site-child' ); ?></h1>
  <p><?php esc_html_e( 'The page you requested could not be found.', 'game-site-child' ); ?></p>
  <?php get_search_form(); ?>
</main>
<?php get_footer(); ?>

The translation domain in the example, game-site-child, must match the child theme’s established text domain if you add translations. Follow the parent theme’s naming conventions for the main element, wrapper classes, hooks, and heading hierarchy. Those details often control layout, menus, breadcrumbs, analytics hooks, and keyboard behavior.

Why the wrapper functions matter

  • get_header() loads the normal header, document opening, navigation, and header hooks supplied by the theme.
  • The content between the wrapper calls is the part you are customizing: explanation, search, navigation links, or a game-related destination.
  • get_footer() closes the page with the parent footer, footer hooks, and scripts that the theme expects.

Removing either wrapper can produce an unstyled page, omit navigation, or break scripts that are registered in the parent shell. If the parent template contains a loop, accessibility skip link, breadcrumb hook, or layout container, preserve it unless you understand the consequences.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Design the recovery path, not just the error message

A visitor who follows an old game guide link, mistypes a slug, or opens a removed article needs a next action. Keep the explanation short and provide routes back into the site:

  • A clear <h1> stating that the page was not found.
  • The primary navigation already supplied by the header.
  • The theme’s search form via get_search_form(), so visitors can search for a game, platform, or article.
  • A link to a stable destination such as the home page, game index, or latest posts page.
  • Optional context-specific links, such as the current game’s category or a platform archive, when those destinations genuinely exist.

Use escaped output for text and attributes, and keep user-controlled query values out of raw HTML. Do not automatically redirect every unknown URL to the home page: a real 404 status tells browsers and search engines that the requested resource is absent, while a redirect changes the meaning of the request.

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Style the child 404 without losing parent assets

Put visual rules in the child stylesheet rather than editing the parent CSS. Scope selectors to the 404 layout or a class on the main wrapper so a large heading or game-card style does not leak into ordinary posts.

.error-404 {
  max-width: 48rem;
  margin-inline: auto;
  padding: 4rem 1.25rem;
  text-align: center;
}

.error-404 a:focus-visible,
.error-404 button:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

If the parent already loads the child stylesheet through normal WordPress child-theme handling, add only the rules you need. If the child CSS is not being loaded, enqueue it from the child theme’s functions.php:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_style(
        'game-site-child-404',
        get_theme_file_uri( '/assets/css/404.css' )
    );
} );

get_theme_file_uri() generates a URL for a file in the active child theme, so the path remains correct when the site moves. Confirm that the file path and handle are unique, then clear any page, browser, or CDN cache before judging the result. If parent selectors are more specific than yours, adjust the child selector deliberately instead of adding broad !important rules.

Build the equivalent page in a block-theme child theme

Block themes do not use a PHP 404.php override for their standard not-found template. Create the directory templates in the child theme, then add templates/404.html. The file contains block comments rather than PHP calls. Header and footer template parts keep the global shell consistent with the rest of the site.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<div class='wp-block-group'>
  <!-- wp:heading {"level":1} -->
  <h1 class='wp-block-heading'>Page not found</h1>
  <!-- /wp:heading -->

  <!-- wp:paragraph -->
  <p>The page you requested could not be found. Try a search or choose a section below.</p>
  <!-- /wp:paragraph -->

  <!-- wp:search {"label":"Search","showLabel":false,"buttonText":"Search"} /-->

  <!-- wp:navigation /-->
</div>
<!-- /wp:group -->

<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->

The exact block attributes should match the parent theme’s existing templates and template-part slugs. A parent may use a different header name, a custom content-width setting, or a navigation block configured in the Site Editor. Copying those conventions avoids a 404 page that looks detached from the rest of the site.

You can edit the template under Appearance → Editor → Templates when the theme exposes it, but save the result in the child theme if you need an update-resistant code-level customization. Check whether the editor stores a user customization that takes precedence over the file; if a file edit does not appear, inspect the template in the Site Editor and remove or update the saved override through the normal editor controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the right override scope

There are two legitimate ways to customize a parent 404. Replacing the whole template gives complete control, while retaining the parent shell and changing only the body reduces maintenance. Decide based on how much of the page must change.

Approach Use it when Main maintenance concern
Copy and replace the complete parent 404 The layout, content structure, or recovery links need a substantially different design. Parent updates may add hooks, wrappers, or accessibility fixes that you must merge manually.
Keep the parent shell and replace only the content area You want the normal header, footer, classes, and hooks with a different message or search block. Your copied section still needs review when the parent changes its surrounding markup.
Use the block child template with existing template parts The active theme is block-based and the change belongs in the Site Editor/template system. Saved editor customizations and file templates can override one another.

For a classic theme, there is no separate child file that automatically injects content into the parent 404 body; the matching 404.php file is the override. Therefore, start from the parent file when preserving its structure matters.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Test the result as a real 404

Testing the visual page alone is not enough. A working custom template must be selected for a genuinely nonexistent request, load the expected shell and assets, provide a recovery path, and return a 404 response.

  1. Open a logged-out or private browser window to avoid administrator-only toolbar changes and stale cached markup.
  2. Visit a URL on the site that is deliberately unlikely to exist, such as a random path under the correct domain. Do not use a URL that a redirect rule intentionally handles.
  3. Confirm that the child design appears, including the expected header, footer, typography, navigation, and search form.
  4. Activate every link and submit a representative search. Check keyboard focus, visible focus indicators, heading order, color contrast, and small-screen wrapping.
  5. Inspect the response in browser developer tools or another HTTP inspection method and verify that the request returns status 404, not a 200 response or an unexpected redirect.
  6. Repeat after clearing page or CDN caches. If the site has separate staging and production caches, purge the relevant layer rather than changing the template again.

Testing an old URL that is supposed to redirect can give a false result. Test both cases separately: a deliberately missing URL should render the custom 404, while a documented redirect should continue to its intended destination.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common failures

The parent 404 still appears

  • Check that the child theme, not the parent, is active.
  • Confirm the file is exactly 404.php at the child-theme root; names such as page-404.php, 404.html, or a file inside templates are not equivalent for a classic theme.
  • Verify that the request is actually a not-found request and is not being redirected or served by a cache.
  • For a block theme, move the work to templates/404.html and check for a saved Site Editor template that takes precedence.

The page is unstyled or the header is missing

Check the opening and closing wrapper calls in a classic template, then inspect the browser’s network panel for the child and parent stylesheets. A missing enqueue, incorrect asset path, or stale cache can hide otherwise correct CSS. If the parent relies on a specific wrapper class, copy that class from its template rather than inventing a replacement.

The search form or links do not work

Ensure the search form is generated with get_search_form() or a valid Search block, and verify that the form submits to the site’s normal search endpoint. Check every recovery link for a valid destination after changing permalinks, category slugs, or game taxonomy names.

The response reports 200 instead of 404

A template can look correct while server or plugin logic changes the status. Review redirect, caching, and custom routing rules, then test a URL that no rule should catch. Do not “fix” the status by redirecting the visitor from the template; the not-found request should remain a 404 unless a separate, intentional redirect rule applies.

A parent update changes the layout

Compare the child copy with the updated parent 404 template. Merge useful new wrappers, hooks, translation changes, and accessibility fixes into the child version while keeping your custom content. This is the trade-off of copying a complete parent template: the child protects your design, but it does not automatically inherit later changes to that file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the customization maintainable

  • Keep the override in the child theme so parent-theme updates do not overwrite it.
  • Document the parent theme version or commit associated with a copied template, making future merges easier.
  • Use the child theme’s established text domain and translation functions for user-facing strings.
  • Escape dynamic values and avoid placing arbitrary request data directly in the page.
  • Preserve a single, logical level-one heading and make the recovery controls usable with a keyboard and screen reader.
  • Keep the page lightweight: reuse the theme’s existing shell and styles instead of loading a separate framework just for the error state.

A custom 404 is successful when it identifies the missing resource, preserves the site’s visual and technical shell, gives visitors a useful next step, and still tells clients that the requested URL does not exist. The implementation is a small child-theme override, but the distinction between PHP and block architectures determines every file path and code sample.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.