Created
October 9, 2019 07:39
-
-
Save dotMastaz/63122c1eda6344321c7ed718a4da92da to your computer and use it in GitHub Desktop.
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', 'cpt_404_redirect' ); | |
function cpt_404_redirect() | |
{ | |
if( is_404()) { | |
global $wp_query; | |
if ( isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'cpt_slug' ) { | |
wp_redirect( home_url( '/your-url/' ) ); | |
exit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment