Created
June 14, 2019 18:46
-
-
Save Asikur22/f23c4e9d80a7a022baf71d0757d9077a to your computer and use it in GitHub Desktop.
Redirect to 404 Page
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
| global $wp_query; | |
| $wp_query->set_404(); | |
| status_header( 404 ); | |
| get_template_part( 404 ); | |
| exit(); | |
| /** | |
| * Show 404 No Found Page on Single View of Custom Post. | |
| */ | |
| function wpse_128636_redirect_post() { | |
| $queried_post_type = get_query_var( 'post_type' ); | |
| if ( is_single() && 'career' == $queried_post_type ) { | |
| global $wp_query; | |
| $wp_query->set_404(); | |
| status_header( 404 ); | |
| get_template_part( 404 ); | |
| exit(); | |
| } | |
| } | |
| add_action( 'template_redirect', 'wpse_128636_redirect_post' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment