404 Putting it all Together

Step 4: Adding the Code for the Image

Okay, now that you have your shiny new 404 graphic and are all jazzed to display it to the world - yea, that you have a broken link - LOL! - let's put the code in.

Returning back to the Theme Editor -

Find the line that shows the text such as:

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

(The reason there are so many spaces before the line is to show hierarchy within the code. You don't have to put in all those spaces, but it works for me.)

Simply add the following line just above (or below) that line of text as such:

<p><center><img src="YOUR-IMAGE-FILE-URL-WEBADDRESS" /></center></p>

Now, OF COURSE, you will replace the URL with the URL of your image file (from Step 3). Leave the double-quotes in there. That's PHP stuff. So, here is mine as an example:

<p><center><img src="http://pureresiduals.com/wp-content/uploads/oops4043.jpg" /></center></p>

Side Note: The < p > thingy is the syntax for the beginning of a paragraph. The ending one is < / p > . Of course there is a Center tag also - and a closing Center tag. That's just like HTML.

Boom! Save the file and test!!!!

I hope you found this useful and FUN!

(Or, is it just me?!)

Cheers!

peej



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