Global 404 for WPMU or WP Multi Sites
By Glenn Ansley | June 22nd, 2010 | Published in WordPress
I quickly drafted the following code in response to this tweet:
I really really really really want a MU universal 404 file.
function global_404() {
if ( is_404() ){
wp_redirect( 'http://site.com/global404' );
die();
}
}
add_action( 'template_redirect', 'global_404' );
If placed inside a plugin that is activated on every site in your network, the above code will do the following:
- Determine that the user looked for a page that didn’t exist.
- Redirect to a URL of your choice, regardless of the site that they are currently viewing.
