WooCommerce产品发布(编辑)页启用古腾堡编辑器的方法

追格官方小助手/ 2022年10月31日/ WordPress/ 浏览 1162

使用WooCommerce的同学应该都知道,WooCommerce的产品发布(编辑)页还是经典编辑器,若我们想和文章一样,开启古腾堡编辑器应该如何操作。


不妨看看追格小编如何操作的,方法比较简单。


function zhuige_activate_gutenberg_product( $can_edit, $post_type ) {
 if ( $post_type == 'product' ) {
        $can_edit = true;
    }
    return $can_edit;
}
add_filter( 'use_block_editor_for_post_type', 'zhuige_activate_gutenberg_product', 10, 2 );

function zhuige_enable_taxonomy_rest( $args ) {
    $args['show_in_rest'] = true;
    return $args;
}
add_filter( 'woocommerce_taxonomy_args_product_cat', 'zhuige_enable_taxonomy_rest' );
add_filter( 'woocommerce_taxonomy_args_product_tag', 'zhuige_enable_taxonomy_rest' );


在当前WordPress模板的functions.php 文件中,添加以上代码即可。

发表评论

暂无评论,抢个沙发...

客服 工单