5 Ways To Customize Your 404 Page

Do you ever read the content when you land on a 404 page?

Do you ever click the links on that page?

Its not the most exciting page to land on is it?

Lets take a look at several ways to add content and customize your 404 page so you can jazz it up a bit.

Exclude Hidden Pages From 404 Page Not Found Error Page

One of the most commonly asked questions when customizing the 404 error page template is ” how do i exclude my hidden pages from the 404 page template?”.

You’ll need to add some code to your template which i have done for you so all you need to do is find the page/post i.d’s you want excluded and add a comma separated list in the page template.

  1. Replace the 2 i.d’s i have included in this code. Example 24,36
  2. Paste all the code into a new file using a code editor like Notepad++
  3. Save it as a 404.php file which you can upload to your child themes root directory.

Create Custom 404.php Template File

Upload this file to the root directoy of your child theme and modify the file to your own requirements.

Using Simple Hooks

You can install a Theme Specific Hooks plugin and add some code to any of the hook locations using a conditional tag for the 404 page template.

Here’s some sample code:

<?php is_page_template( '404.php' ) ) { ?>
<p>HTML-Code-Goes-Here</p>
<?php } ?>

Or you can use the conditional tag for the 404 page:

<?php is_404()) { ?>
<p>HTML=Code-Goes-Here</p>
<?php } ?>

Paste the code with the HTML for your image or text into any of the Genesis Simple Hooks fields.

404 conditional tag

Custom 404 Page Plugin

Here’s 2 plugins which enable you to customize your 404 page.

Genesis 404 Page

Genesis Widgetized Not Found

Add Conditional Tag To Widget Logic

If you already have a widget area in the location you want to display content on your 404 page, you can simply add the conditional tag for the 404 page to the widget after installing the Widget Logic plugin.

widget logic 404 conditional tag

There’s at least 2 conditional tags you can use:

is_404

Page template conditional tag

is_page_template( '404.php' )

You can also copy the 404 page not found template from the Genesis parent theme to your child themes folder and add custom code directly to the template file there.

Customize 404 Page Template

Once you’ve copied your 404 page template (404.php) to your child themes folder, you can add code directly to the template file.

You could also copy another page template and rename it 404.php in your child theme.

And you can customize/edit the default text contained in the 404 page template to anything you like:

Edit 404 Page Text

Add The Default WordPress Search Tag in 404 Page Template

Another option is to paste in the WordPress search tag directly into your custom 404 page template to display a search box.

The WordPress search box tag is:

<?php get_search_form(); ?>

This will output the search form in the location you place the tag in your 404 page template.

Customize 404 page template

You could also add the get search form tag to a custom function or a hook plugin field in the location you want to display your search form.

Learn more about creating a custom search page template in WordPress.

Add Widget Area To 404 Page

Add code from this tutorial to the end of your child themes functions.php file.

You can modify one of the code snippets by adding a theme specific hook like genesis_header and changing the conditional tag to is_404() if needed or adding the conditional tag directly the widget using the Widget Logic plugin.

Conclusion

How about you?

Have you seen any cool looking 404 page not found error pages or customized your won 404 page?

Related 404 Page Articles


Comments

9 responses to “5 Ways To Customize Your 404 Page”

  1. Hi, great article!

    I have a category pages that don’t have any content yet.
    The message says “Sorry, no content matched your criteria.”
    Is there a way I can modify this text for example to “coming soon”?

    1. Brad Dalton Avatar
      Brad Dalton

      Yes, you can change the text in the loop which generates the message.

      Or you can modify the default text output using a filter hook in a custom function.

  2. This would be the actual code, given in image.

    1. Brad Dalton Avatar
      Brad Dalton

      Sorry, don’t follow.

      Can you please clarify?

  3. Stephen Avatar

    Hey Brad,

    You just replied to my post on the Genesis forum and then I recognized here. I use Genesis framework with Dynamik Website Builder child theme. I couldn’t figure out all the php with the custom 404, so I created a file with the following code, named it “404.php” file, and uploaded it into my child theme:

    Then I just created a custom page in wordpress and named it “sorry”.

    The disadvantage is that the visitor can’t see if they made a typo in the url, but I can barely code css, let alone php, so this was the workaround. Now it fits in with my other site pages.

    1. Brad Dalton Avatar
      Brad Dalton

      Thanks for sharing your solution Stephen.

      1. Stephen Avatar

        must have forgotten to leave the “following code:”

        (or maybe the form doesn’t accept it

        1. Brad Dalton Avatar
          Brad Dalton

          You can wrap it in opening and closing code short-codes

          1. Stephen Avatar

            (Should have known that already. Now I won’t forget.)

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.