
创建和定制WordPress导航菜单的深入浅出教程
_disable_content_editor_for_navigation_post_type ( $post )
_disable_content_editor_for_navigation_post_type: 这个函数用于禁用导航文章类型的内容编辑器: 这是为了保持对尚未过渡到使用区块编辑器的旧WordPress主题的向后兼容性。
这个回调可以禁用wp_navigation类型文章的内容编辑器。
内容编辑器不能正确处理wp_navigation类型的文章。
我们不能禁用wp_navigation的CPT定义中的”编辑器”功能,因为它禁用了通过REST API保存导航区块的权限。
function _disable_content_editor_for_navigation_post_type( $post ) { $post_type = get_post_type( $post ); if ( 'wp_navigation' !== $post_type ) { return; } remove_post_type_support( $post_type, 'editor' ); }