I am creating a new WordPress Theme and would like to use the Classic Editor specifically on the front page. To achieve this, I plan to modify the functions.php file with a few lines of code instead of relying on a plugin.
I would like to maintain the Gutenberg editor for other pages and posts.
Despite trying different methods, I have not found a solution that worked. Or I am able to remove the Gutenberg Editor from all the pages, or not remove it at all.
That's my most recent try.
Does someone know what can I do?
Thanks a lot!!!
function use_classic_editor_on_front_page( $use_block_editor, $post_type ) {
if ( ! is_admin() && is_front_page() && 'page' === $post_type ) {
return false;
}
return $use_block_editor;
}
add_filter( 'use_block_editor_for_post_type', 'use_classic_editor_on_front_page', 10, 2 );
Eventually, (and thanks to the direction Asiqur gave me) I found another solution that goes even more in detail, removing the block editor from a specific page, in this case, the one with the title "Home". Decided to share it here.
add_filter('use_block_editor_for_post_type', 'use_classic_editor_on_page_name', 10, 2);
function use_classic_editor_on_page_name($use_block_editor, $post_type)
{
if ($post_type === 'page' && get_the_title() == 'Home') {
$use_block_editor = false;
remove_post_type_support('page', 'editor');
} else if ($post_type === 'page' && get_the_title() !== 'Home') {
$use_block_editor = true;
} else if ($post_type === 'post') {
$use_block_editor = true;
}
return $use_block_editor;
}