Browse: Home / Snippets /

Disable Gutenberg on LearnDash Custom Post Types

Contents


Snippet #

/**
 * LearnDash - Example filter to disable Gutenberg Editor on any of
 * the LearnDash custom post types.
 */
add_filter( 'use_block_editor_for_post_type', function ( $use_gutenberg, $post_type ) {
	$ld_course_types = array( 'sfwd-courses', 'sfwd-lessons', 'sfwd-topic', 'sfwd-quiz', 'sfwd-question', 'groups' );
	if ( in_array( $post_type, $ld_course_types ) ) {
		$use_gutenberg = false;
	}

	// Always return $use_gutenberg.
	return $use_gutenberg;
}, 30, 2 );