Skip to content

Instantly share code, notes, and snippets.

@josephabrahams
Last active December 30, 2015 04:39
Show Gist options
  • Save josephabrahams/7777449 to your computer and use it in GitHub Desktop.
Save josephabrahams/7777449 to your computer and use it in GitHub Desktop.
404 all WordPress requests that don't match a theme template
<?php
$f_path = dirname( realpath( __FILE__ ) ) . '/../../../404.html';
if ( file_exists( $f_path ) ) {
readfile( $f_path );
} else {
echo '<h1>404 Not Found</h1>';
}
<?php
global $wp_query;
$wp_query->set_404();
status_header( 404 );
get_template_part( 404 );
@josephabrahams
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment