How To Change Your WordPress 404 To An Image

How-To-Change-Your-WordPress-404-To-An-Image

If your theme is worth it’s salt you should be able to edit it’s 404.php file to include a custom 404 image instead of a boring old text one. This is just another way of making your blog unique.

Place the following code in your 404.php before get_header():

// @version 2011.12.23
// matches 'img.png' and 'img.gif?hello=world'
if ( preg_match( '~\.(jpe?g|png|gif|svg|bmp)(\?.*)?$~i', $_SERVER['REQUEST_URI'] ) )
{
    header( 'Content-Type: image/png' );
    locate_template( 'img/404.png', TRUE, TRUE );
    exit;
}

Examples

Of course it would be really cool to come up with your own!

Incoming search terms:

  • change wordpress 404 (3)
  • how to picture in your 404 (2)
  • wordpress how to change 404 (1)
  • wordpress custom 404 php (1)
  • wordpress 404 images (1)
  • how to set image wordpress 404 (1)
  • 404 php wordpress image (1)
  • how to change the 404 page in wordpress (1)
  • custom 404 image wordpress (1)
  • change 404 image in wordpress (1)

Find More Like This:

Post comment as twitter logo facebook logo
Sort: Newest | Oldest
alana Alanadoris 5 pts

Good for sharing a informative post...Nice to go around your blog..