Replace “content-area” of themes 404 page with plugin?

According to the Template Page hierarchy, https://developer.wordpress.org/files/2014/10/wp-hierarchy.png the only template page WP will load is 404.php

But, you might try this in your mu-plugins:


//Some function to check database to see if this URL should exist
if ( ! checkIfPageExists( $_SERVER['REQUEST_URI'] ) ) {
//Set 404 Status
status_header( "404" );
get_header();
//do your custom 404 code here
get_footer();
}

I’m not sure it’ll work, but give it a try

error code: 523