if( $shit == false ) { // Term don't exist, throw a 404 header('HTTP/1.1 404 Not Found'); global $wp_query; $wp_query->set_404(); // Needed for the body class $_GET['e'] = 404; // Set the variable for the error code (you cannot have a querystring in an include directive). include get_template_directory() . '/404.php'; exit(); }