Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk10 min

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

A practical guide to overriding a parent theme’s not-found page safely, with classic PHP and block-theme instructions, code examples, styling guidance, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a classic WordPress theme, create a file named 404.php in the root of the active child-theme directory. WordPress uses that file for not-found requests, and the child file takes precedence over a parent theme’s file with the same name. Keep get_header() at the beginning and get_footer() at the end so the normal site shell remains available.

If the site uses a block theme, the equivalent file is templates/404.html. The implementation is different, but the goal is the same: explain that the URL is unavailable and give visitors a useful way back through navigation, search, or a relevant destination.

As an Amazon Associate I earn from qualifying purchases.

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.

First identify whether the active theme is classic or block-based

The correct 404 file depends on the architecture of the active parent theme. A classic theme renders templates with PHP files such as index.php, while a block theme stores site templates in HTML files under a templates directory.

Theme architecture Child-theme file How you edit it Shared shell
Classic PHP theme 404.php in the child-theme root PHP, HTML, WordPress template tags and hooks get_header() and get_footer()
Block theme templates/404.html Block markup and template-part references Header and footer template-part blocks

On a classic theme, WordPress checks for 404.php before falling back to index.php. If a child theme contains a file with the same name as one in its parent, the child version overrides the parent version. That lets you change the not-found view without editing files that a parent-theme update may replace.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Create and activate the child theme

If a child theme is already active, skip to the section for your theme architecture. Otherwise, create the child before changing the 404 template.

Build the required child-theme files

Create a new directory inside wp-content/themes. Give it a distinct name, such as my-site-child. Add a style.css file with a child-theme header. The Template value must exactly match the parent theme’s directory name, including capitalization where the filesystem distinguishes it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/*
Theme Name: My Site Child
Template: twentytwentyfour
*/

The example uses twentytwentyfour only as an illustration. Replace it with the directory name of the parent theme installed on your site. If the parent relationship is wrong, WordPress will not treat the directory as a child of that theme.

Activate it in the dashboard

  1. Open Appearance > Themes in the WordPress dashboard.
  2. Locate the child theme and select Activate.
  3. Visit the front end and check the home page, a post, and an archive before editing the 404 view. This establishes that the parent theme still supplies its normal templates and assets.

Make a backup of the child-theme files before substantial edits. You can work through a host file manager, SFTP, or a local development copy; the important requirement is that the file ends up in the active child-theme directory.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Create 404.php for a classic theme

Put the file in the child-theme root

Create wp-content/themes/my-site-child/404.php, alongside the child theme’s style.css. Do not put it in the parent directory and do not place it inside a folder such as templates unless the parent theme specifically uses a separate system for loading that file. The classic template hierarchy expects the filename 404.php at the theme level.

Start with the parent structure when possible

Copying the parent theme’s 404 structure is often the safest starting point. It preserves classes, hooks, wrapper elements, and accessibility behavior that the rest of the theme expects. Then change only the content and markup you need. If you replace the complete file, retain any parent-specific hooks that are required for menus, breadcrumbs, analytics, or layout wrappers.

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

Use the normal header and footer wrappers

A minimal, valid child template looks like this:

<?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', 'my-site-child' ); ?></h1>
  <p><?php esc_html_e( 'The page you requested could not be found.', 'my-site-child' ); ?></p>
  <?php get_search_form(); ?>
</main>
<?php get_footer(); ?>

get_header() loads the theme’s shared header and begins the normal page shell. The custom content belongs between that call and get_footer(), which closes the shell and loads the footer. The text domain in the example, my-site-child, should match the child theme’s translation domain if you provide translations.

The heading should identify the problem without relying on color or a graphic. A short explanation can tell visitors that the link may be outdated or that the address was typed incorrectly. Keep the main heading as the page’s first meaningful heading so screen-reader users can understand the state immediately.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Add recovery actions instead of an error message alone

get_search_form() prints the theme’s search form, allowing visitors to look for the content they expected. You can place a link to the home page, a key section, or a current archive below it. Use normal WordPress escaping functions for text and attributes, and keep links descriptive rather than using vague labels such as “click here.”

<?php
$home_url = home_url( '/' );
?>
<p>
  <a href='<?php echo esc_url( $home_url ); ?>'>
    <?php esc_html_e( 'Go to the home page', 'my-site-child' ); ?>
  </a>
</p>

If you add a list of destinations, choose links that remain useful when individual posts or products change. A primary navigation link, a search form, and one broad category are generally more resilient than a collection of links to old campaigns.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Style the child-theme 404 page without breaking the parent layout

Use the child stylesheet

Place 404-specific rules in the child theme’s stylesheet rather than editing the parent stylesheet. A focused set of rules can style the message, search form, and recovery links while inheriting typography and spacing from the parent.

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

.error-404 .search-form {
  display: grid;
  gap: .75rem;
  max-width: 32rem;
  margin: 2rem auto;
}

Add a matching class to the main element, for example class='site-main error-404'. Check the parent’s naming conventions first; reusing its existing container classes can avoid duplicate width and padding rules.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Enqueue the stylesheet explicitly when the parent does not load it

Many themes load a child stylesheet automatically, but that behavior is not universal. If your rules do not appear, enqueue the file from the child theme’s functions.php on wp_enqueue_scripts.

<?php
function my_site_child_enqueue_styles() {
    wp_enqueue_style(
        'my-site-child-style',
        get_theme_file_uri( 'style.css' ),
        array(),
        null
    );
}
add_action( 'wp_enqueue_scripts', 'my_site_child_enqueue_styles' );

get_theme_file_uri( 'style.css' ) generates the URL for the file in the active theme, including the child theme. If the parent already enqueues a stylesheet with the same handle or the child stylesheet is visibly loaded in the page source, do not add a second enqueue merely to duplicate it.

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

Reference child-theme assets correctly

For an image, script, or additional stylesheet stored in the child theme, generate its URL with get_theme_file_uri() rather than hard-coding the site address. For example:

<img src='<?php echo esc_url( get_theme_file_uri( 'assets/404-illustration.svg' ) ); ?>' alt=''>

An empty alt value is appropriate only when the illustration is decorative and the surrounding text already conveys the message. If the image contains information that visitors need, provide a useful alternative description.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Customize a 404 page in a block child theme

Block themes use templates/404.html, not 404.php. Create a templates directory in the child theme and add the file there. Edit it with block markup, and use template-part blocks for the shared header and footer.

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

<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main 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.</p>
  <!-- /wp:paragraph -->

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

  <!-- wp:paragraph -->
  <p><a href='/'>Go to the home page</a></p>
  <!-- /wp:paragraph -->
</main>
<!-- /wp:group -->

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

The exact block attributes and available template parts depend on the active theme. If the parent uses custom header or footer slugs, copy those references from its existing templates. You can also design the 404 template in Appearance > Editor when the site exposes template editing, then keep the resulting template in the child theme if you need the customization to survive a parent update.

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

Do not mix a PHP-only layout into 404.html. Block templates are parsed as block markup, so an unrecognized PHP call will appear as text or be ignored rather than loading the classic shell.

Choose how much of the parent 404 template to replace

Approach When it fits Benefit Risk to check
Copy and adapt the complete parent template The parent’s 404 view contains required wrappers, hooks, breadcrumbs, or theme-specific components Preserves the parent’s established structure while giving you full control of content Parent updates can introduce changes that your copied file no longer receives
Build a small child template around the standard shell You need a simple message, search form, and a few recovery links Less code to maintain and easier to understand Leaving out parent classes or hooks can affect styling or integrations
Use the block template editor The active theme is block-based and the site team prefers visual editing Uses native blocks and template parts Theme-specific template-part names and editor availability vary

Whichever route you choose, keep the customization in the child theme. Editing the parent’s 404.php or block template directly makes the change vulnerable to the next parent-theme update.

Test the result as a real not-found response

  1. Open a private or logged-out browser window so cached editor previews and administrator notices do not affect the result.
  2. Request a deliberately nonexistent URL on the site, such as a random path that you will not use elsewhere.
  3. Confirm that the new heading, message, search form, navigation, and visual styles appear inside the normal site header and footer.
  4. Submit the search form and follow each recovery link. Make sure they lead to useful pages and that keyboard focus remains visible.
  5. Check the response status in your browser’s developer tools or with an HTTP header checker. A custom design must still return a real 404 status rather than a successful 200 response.
  6. Repeat the check on a phone-sized viewport and with keyboard navigation. Long headings, search controls, and links should remain usable without horizontal scrolling.

Test more than one missing URL if your site has language prefixes, custom post-type bases, or unusual permalink rules. A template can look correct for one route while a redirect or plugin handles another route differently.

Troubleshoot common problems

The parent 404 page still appears

  • Verify that the file is named exactly 404.php and is in the active child-theme root.
  • Open Appearance > Themes and confirm the child, not the parent, is active.
  • Check that the child directory is the one shown by the active theme and that the file was uploaded there.
  • Clear page, object, and browser caches after saving the file.

The page has no styling or loses the header and footer

  • Confirm that get_header() and get_footer() are present in the PHP template.
  • Compare your wrapper classes with the parent’s original 404 template.
  • Inspect the page source to see whether the child stylesheet is loaded; if not, enqueue it from functions.php.
  • Look for PHP syntax errors, especially a missing semicolon or an unclosed brace in functions.php.

The block template is ignored

  • Confirm that the active theme is a block theme and that the file is exactly templates/404.html in the child directory.
  • Validate the opening and closing block comments. A missing closing comment can cause later markup to be interpreted incorrectly.
  • Use the parent theme’s actual template-part slugs for its header and footer.
  • Clear caches and test a fresh nonexistent URL after saving.

The search form or links do not work

  • Check that the form is generated by get_search_form() or a valid Search block rather than copied markup with missing form fields.
  • Follow links while logged out; administrator-only destinations can appear to work during development but fail for visitors.
  • Use escaped URLs and text output when values come from WordPress functions or other variables.

Keep the template maintainable

Document the reason for the child override in a PHP comment or a project changelog. Record the parent theme version and the classes or hooks that your design depends on. When the parent theme updates, compare its new 404 template with your child copy so you can bring across important accessibility, markup, or integration changes deliberately.

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

Keep the 404 template focused on recovery. Avoid loading a second navigation system, autoplaying media, or a large decorative asset that delays the useful controls. A clear heading, short explanation, search, and a small set of dependable destinations are enough for most sites.

Quick implementation checklist

  • Identify whether the active parent is classic PHP or block-based.
  • Activate a child theme with a correct Template relationship before editing files.
  • Use 404.php at the child root for classic themes.
  • Use templates/404.html for block themes.
  • Retain the parent’s wrappers, classes, hooks, and template parts where they matter.
  • Keep get_header() first and get_footer() last in a classic template.
  • Provide search and useful navigation or destination links.
  • Load child CSS through the existing theme mechanism or enqueue it with wp_enqueue_style().
  • Generate child-asset URLs with get_theme_file_uri().
  • Test as a logged-out visitor and confirm a genuine 404 response.

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 from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair 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.