A simple guide to redirecting 404 error pages to your homepage in WordPress for a better user experience.
add_action( 'template_redirect', function() {
if (is_404()) {
wp_safe_redirect(home_url());
exit();
}
} );
A simple guide to redirecting 404 error pages to your homepage in WordPress for a better user experience.
add_action( 'template_redirect', function() {
if (is_404()) {
wp_safe_redirect(home_url());
exit();
}
} );