Where does WordPress call the 404 page ?

If you click Appearance and then select theEditor option as such:

This is the file editor for your theme's actual pages - coded in a language known as PHP. It's much like HTML stuff. And, you can actually insert HTML code within PHP. WordPress is built on PHP, by the way.

Okay, so here is the code for a standard WordPress 404 . php file (using the stock theme - Twenty Thirteen)

<?php/** * The template for displaying 404 pages (Not Found) * * @package WordPress * @subpackage Twenty_Thirteen * @since Twenty Thirteen 1.0 */get_header(); ?>    <div id="primary" class="content-area">        <div id="content" class="site-content" role="main">            <header class="page-header">                <h1 class="page-title"><?php _e( 'Not Found', 'twentythirteen' ); ?></h1>            </header>            <div class="page-wrapper">                <div class="page-content">                    <h2><?php _e( 'This is somewhat embarrassing, isn't it?', 'twentythirteen' ); ?></h2>                    <p><?php _e( 'It looks like nothing was found at this location. Maybe try a search?', 'twentythirteen' ); ?></p>                    <?php get_search_form(); ?>                </div><!-- .page-content -->            </div><!-- .page-wrapper -->        </div><!-- #content -->    </div><!-- #primary --><?php get_footer(); ?>

So, at the top, you'll notice the "call" to get the header file. Then, there's a "div" for a "page" container (they call areas of a page containers.)

Anyway, on down a bit is a "div class" for the title of the page to be shown - this section here:

<h1 class="page-title"><?php _e( 'Not Found', 'twentythirteen' ); ?></h1>

So, the "Not Found" becomes the title - just like on any other page.

There is also an H2 (subtitle) located here:

<h2><?php _e( 'This is somewhat embarrassing, isn’t it?', 'twentythirteen' ); ?></h2>

Then, on down a wee bit more there is a PHP echo command that spits out the text you will see in the body of the page:

<p><?php _e( 'It looks like nothing was found at this location. Maybe try a search?', 'twentythirteen' ); ?></p>

That's the text body that is normally see for most themes.




Join the Discussion
Write something…
Recent messages
ZeeA Premium
Thanks for sharing Peej. If we're not aware yet of the presence of broken link in our site, is there anyway to check it all or we got to check all the link manually?
Reply
EKautz Premium
lol - More great stuff Peej, and very humorous too! Greatly appreciate bro!

ROCK ON!
E
Reply
Shawn Martin Premium
Nice work :)
Reply
PjGermain Premium
Much appreciated Shawn!!
Reply
DHagstrom Premium
Do I just do this within the code for the theme itself, or should this be set up within a child theme?
Reply
BobBarr Premium
Code changes to a theme's files should be done through a child theme. Otherwise, any manual changes that you make will be overwritten whenever the theme is updated. Because of this, you'll need to reenter the changes every time the theme gets updated.

Since a child theme works by overriding the coding in its parent theme, theme updates don't affect those overrides. (Updates only change the parent theme's files; there won't be any updating done to your child theme files.)
Reply
PjGermain Premium
Agreed! Thanks very much Bob !!
Reply
DHagstrom Premium
Thanks to both of you, Bob & PJ!
Reply
kennick2015 Premium
Good post PJ. 404 pages can also be used to send a visitor back to a landing or squeeze page by adding the respective link. Cheers Ken.
Reply
PjGermain Premium
Yep, quite right Ken! Thanks very much
Reply
Top