Last active
December 5, 2018 07:02
-
-
Save oliwa/1584af30166058602a2be3526cf18bce to your computer and use it in GitHub Desktop.
Redirect single-ctp.php to homepage
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 | |
// How to disable the single view for a custom post type | |
// see https://wordpress.stackexchange.com/questions/128636/how-to-disable-the-single-view-for-a-custom-post-type | |
add_action( 'template_redirect', 'wpse_128636_redirect_post' ); | |
function wpse_128636_redirect_post() { | |
$queried_post_type = get_query_var('post_type'); | |
if ( is_single() && 'my_post_type_name' == $queried_post_type ) { | |
wp_redirect( home_url(), 301 ); | |
exit; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wordpress.stackexchange.com/questions/128636/how-to-disable-the-single-view-for-a-custom-post-type