WooCommerce产品发布如何启用古腾堡编辑器

文 / @UTHEME

几年时间过去了,古腾堡(Gutenberg)编辑器不断完善,目前的内容编辑体验还是不错的。然而 WooCommerce 还是采用经典编辑器,所以今天我们就分享下 为 WooCommerce 的产品发布启用古腾堡编辑器的方法。如果你想在WooCommerce产品发布页面启用古腾堡编辑器,可以按照以下步骤操作:

只需要将下面的代码添加到当前主题的 functions.php 即可:

// Enable Gutenberg editor for WooCommerce
function 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', 'wpkj_activate_gutenberg_product', 10, 2 );
// enable taxonomy fields for woocommerce with gutenberg on
function wpkj_enable_taxonomy_rest( $args ) {
$args['show_in_rest'] = true;
return $args;
}
add_filter( 'woocommerce_taxonomy_args_product_cat', 'activate_gutenberg_product' );
add_filter( 'woocommerce_taxonomy_args_product_tag', 'activate_gutenberg_product' );

在启用了古腾堡编辑器后,你就可以在WooCommerce产品发布页面中使用它来编辑产品描述和其他内容了。古腾堡编辑器提供了丰富的文本编辑功能,可以让你轻松地排版和格式化文本内容,使产品信息更加清晰易懂。

添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。