Created
May 7, 2018 06:43
-
-
Save ksuzushima/f9eb3efcda33a6f8e3a485b7f4acee83 to your computer and use it in GitHub Desktop.
Redirect 404 status #wordpress
This file contains 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
<?php | |
/** | |
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect | |
* @link https://developer.wordpress.org/reference/classes/wp_query/set_404/ | |
*/ | |
function status404() { | |
if ( is_singular( 'hoge' ) ) { | |
global $wp_query; | |
$wp_query->set_404(); | |
status_header( 404 ); | |
} | |
} | |
add_action( 'template_redirect', 'status404' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment