So I don't want to dive into the whys behind what I need to do but I have a very important piece of code that I need to insert into the 404 page regardless of the theme as a replacement of the content-area div. So below the get_header in replacement of the content-area and before the get_sidebar/get_footer.

Currently I have to install this piece of code into every themes 404 page before I can install it on my multisite, I'd like to accomplish this through a plugin but can't seem to override the themes 404 page.


1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.