NB: Make sure you do a back up of your theme, files and database before attempting the tutorials

Redirection des pages 404
Web Hosting Canada

Last modified : Dec 24 2022

Estimated reading time : 0 minutes, 47 seconds - 74 words

Redirecting 404 pages: There are many ways and reasons to redirect your 404 pages. With this tutorial, we will redirect 404 pages to the homepage with the template_redirect hook.

Redirecting your 404 pages

add_action('template_redirect', 'themespress_redirect_404_to_homepage', 999);
function themespress_redirect_404_to_homepage(){

This function will ensure that all 404 oages will be redirected and in this case a 404.php template is not necessary in your theme.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>