# Block Pattern: Helpful 404 Page Content

> Adds a friendly 404 pattern with a message, a search box and a button home, offered when you edit the 404 template in the Site Editor.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: patterns, 404, site-editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pattern-404-helpful/

## Code

```php
add_action( 'init', function () {
    if ( ! function_exists( 'register_block_pattern' ) ) {
        return;
    }

    $content = '<!-- wp:group {"layout":{"type":"constrained"}} --><div class="wp-block-group">'
        . '<!-- wp:heading {"textAlign":"center","level":1} --><h1 class="wp-block-heading has-text-align-center">We could not find that page</h1><!-- /wp:heading -->'
        . '<!-- wp:paragraph {"align":"center"} --><p class="has-text-align-center">The link may be old or mistyped. Try a search, or head back to the homepage.</p><!-- /wp:paragraph -->'
        . '<!-- wp:search {"label":"Search","showLabel":false,"buttonText":"Search"} /-->'
        . '<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} --><div class="wp-block-buttons"><!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="/">Back to the homepage</a></div><!-- /wp:button --></div><!-- /wp:buttons -->'
        . '</div><!-- /wp:group -->';

    register_block_pattern( 'wpide/404-helpful', array(
        'title'         => '404: helpful message with search',
        'description'   => 'Friendly not-found message, search box and home button.',
        'categories'    => array( 'text' ),
        'keywords'      => array( '404', 'not found', 'error' ),
        'templateTypes' => array( '404' ),
        'content'       => $content,
    ) );
} );
```

## Notes

Open Appearance > Editor > Templates > Page: 404 and pick it from the patterns offered for that template.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Pattern: Helpful 404 Page Content" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
