Skip to main content

Disable Single Template for Custom Post

Written by the Divi Engine Documentation Team

Introduction

If you want to disable ONLY the single page for your custom post you will need to add some custom PHP code. Add the following to your functions.php of your child theme OR if not using a child theme, use a plugin like Code Snippets. Change the name "cpt_slug" to be the slug of your custom post

php
add_action( 'template_redirect', 'de_redirect_single_template' );
function de_redirect_single_template() {
if ( is_singular( 'cpt_slug' ) ) {
wp_redirect( home_url(), 301 );
exit;
}
}
?