Skip to content

Instantly share code, notes, and snippets.

@khromov
Created May 24, 2016 20:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khromov/a627112f83d1a336643c5ebe89cebbff to your computer and use it in GitHub Desktop.
Save khromov/a627112f83d1a336643c5ebe89cebbff to your computer and use it in GitHub Desktop.
Set a page with slug "404-error" as your 404 page in WordPress
<?php get_header(); ?>
<div class="container-fluid">
<div class="content">
<main role='main'>
<?php
$query_404 = new WP_Query(array(
'posts_per_page' => 1,
'post_type' => 'page',
'post_name' => '404-error'
));
while ( $query_404->have_posts() ) : $query_404->the_post();
get_template_part( 'content', 'page' );
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile;
wp_reset_postdata();
?>
</main>
</div>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment