To redirect 404 error to homepage you may add the little snippet code to your functions.php
/** * WordPress 404 Redirect to Home */ function homepage_redirect_404() { global $wp_query; if ( $wp_query->is_404 ) { wp_redirect( get_bloginfo( 'wpurl' ), 301 ); exit; } } add_action( 'template_redirect', 'homepage_redirect_404', 1 );
We’ve tried our best to explain everything thoroughly, even though there’s so much information out there. If you found our writing helpful, we’d really appreciate it if you could buy us a coffee as a token of support.
Also, if you’re interested in learning more about WordPress, Javascript, HTML, CSS, and programming in general, you can subscribe to our MailChimp for some extra insights.