添加 'page-attributes' 到 woocommerce 支持
Add 'page-attributes' to woocommerce supports
woocommerce插件默认只支持
$supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields',
'publicize', 'wpcom-markdown' );
在class-wc-post-types.php。我想使用默认的 page-attributes
来支持 Woocommerce CPT。是否有 function/filter 可以利用 class?
I want to utilize the default page-attributes into the supports for the Woocommerce CPT. Is there a function/filter available to tap into that class?
看那个class的源代码,好像不是。
但是您可以通过 add_post_type_support
.
修改已经存在的 post 类型支持
感谢@cBroe。这适用于 post 类型。如果 woocommerce 处于活动状态,我只是添加了一个工作条件。
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
function wpcodex_add_excerpt_support_for_pages() {
add_post_type_support( 'product', 'page-attributes' );
}
add_action( 'init', 'wpcodex_add_excerpt_support_for_pages' );
}
woocommerce插件默认只支持
$supports = array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields',
'publicize', 'wpcom-markdown' );
在class-wc-post-types.php。我想使用默认的 page-attributes
来支持 Woocommerce CPT。是否有 function/filter 可以利用 class?
I want to utilize the default page-attributes into the supports for the Woocommerce CPT. Is there a function/filter available to tap into that class?
看那个class的源代码,好像不是。
但是您可以通过 add_post_type_support
.
感谢@cBroe。这适用于 post 类型。如果 woocommerce 处于活动状态,我只是添加了一个工作条件。
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
function wpcodex_add_excerpt_support_for_pages() {
add_post_type_support( 'product', 'page-attributes' );
}
add_action( 'init', 'wpcodex_add_excerpt_support_for_pages' );
}