<?php add_action( 'template_redirect', 'wpse_128636_redirect_post' ); function wpse_128636_redirect_post() { if ( is_singular( 'sample_post_type' ) ) { wp_redirect( home_url(), 301 ); exit; } } ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter