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.
- Replace the 2 i.d’s i have included in this code. Example 24,36
- Paste all the code into a new file using a code editor like Notepad++
- 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.
Custom 404 Page Plugin
Here’s 2 plugins which enable you to customize your 404 page.
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.
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:
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.
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?
Was This Tutorial Helpful?