Created
August 24, 2019 15:17
-
-
Save deeman/53403645af4117c3f21ea3815185f703 to your computer and use it in GitHub Desktop.
WordPress Snippet: 404 Redirect To Any URL
This file contains hidden or 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
| add_action( 'template_redirect', 'redirect_404_to_any_url' ); | |
| function redirect_404_to_any_url() { | |
| if ( is_404() ) : | |
| wp_redirect( 'http://example.com/', 301 ); | |
| exit; | |
| endif; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment