Skip to content

Instantly share code, notes, and snippets.

@Vheissu
Last active December 13, 2015 23:39
Show Gist options
  • Save Vheissu/4993316 to your computer and use it in GitHub Desktop.
Save Vheissu/4993316 to your computer and use it in GitHub Desktop.
Custom 404 page template for displaying a custom editable Wordpress 404 page.
<?php get_header(); ?>
<?php
$the_page = null;
$errorpageid = get_option( '404pageid', 0 );
if ($errorpageid !== 0) {
// Typecast to an integer
$errorpageid = (int) $errorpageid;
// Get our page
$the_page = get_page($errorpageid);
}
?>
<div id="four-oh-four">
<?php if ($the_page == NULL || isset($the_page->post_content) && trim($the_page->post_content == '')): ?>
<h1>There was an error and nobody defined a custom 404 page message, so you're seeing this instead.</h1>
<?php else: ?>
<?php echo apply_filters( 'the_content', $the_page->post_content ); ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment