Friday, 29 July 2022

Error page redirect on 404 page.

 add_action( 'template_redirect', 'unlisted_jobs_redirect' );

function unlisted_jobs_redirect() {

if(is_404()) {

global $wp;

$link = home_url($wp->request);

$link_array = explode('/',$link);

$page_not_found = end($link_array);

if($page_not_found != 404) {

wp_redirect( home_url( '/404/' ) );

exit();

}

}

}        

No comments:

Post a Comment