Created
February 2, 2017 09:36
-
-
Save bigdigital/af5a2f307368ab59415f7a68aa39c76f to your computer and use it in GitHub Desktop.
Wordpress redirect 404 error to custom page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_404_page_redirect() { | |
global $wp_query; | |
if ($wp_query->is_404) { | |
wp_redirect('http://example.com',301); | |
exit; | |
} | |
} | |
add_action('wp', 'custom_404_page_redirect', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment