Closed inc2734 closed 8 months ago
サンプルコード
/** * If the front page is not used, front-page.html should not be used. */ function unitone_hidden_front_page_template_on_blog( $templates ) { $show_on_front = get_option( 'show_on_front' ); $page_on_front = get_option( 'page_on_front' ); $page_template = get_post_meta( $page_on_front, '_wp_page_template', true ); if ( 'page' !== $show_on_front || ! $page_on_front || ( $page_template && 'default' !== $page_template ) ) { foreach ( $templates as $index => $template ) { if ( 'front-page' === $template->slug ) { unset( $templates[ $index ] ); } } } return $templates; } add_filter( 'get_block_templates', 'unitone_hidden_front_page_template_on_blog' );
サンプルコード