Skip to content

Instantly share code, notes, and snippets.

@joshapgar
Created September 11, 2020 20:09
Show Gist options
  • Save joshapgar/ab4dfd9e98054dd708c1cec180513dbe to your computer and use it in GitHub Desktop.
Save joshapgar/ab4dfd9e98054dd708c1cec180513dbe to your computer and use it in GitHub Desktop.
<?php
function activate_gutenberg_for_post_type( $is_enabled, $post_type ) {
if ( 'post-type-name-here' == $post_type ) {
return true;
} elseif('page' == $post_type) {
global $post;
$pageTemplate = get_post_meta($post->ID, '_wp_page_template', true);
if($pageTemplate == 'page-template-name-here.php') {
return true;
} else {
return false;
}
} else {
return false;
}
return $is_enabled;
}
add_filter( 'use_block_editor_for_post_type', 'activate_gutenberg_for_post_type', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment