Woocommerce子主题-在子主题中重写Woocommerce支持



我使用下划线作为父主题。它像这样声明Woocommerce支持:

function _s_woocommerce_setup() {
add_theme_support(
'woocommerce',
array(
'thumbnail_image_width' => 150,
'single_image_width'    => 300,
'product_grid'          => array(
'default_rows'    => 3,
'min_rows'        => 1,
'default_columns' => 4,
'min_columns'     => 1,
'max_columns'     => 6,
),
)
);
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );

}

如何删除或覆盖子主题中的设置。例如,我希望子主题的缩略图宽度为300px。这是如何实现的呢?我可以删除主题支持并重新添加吗?

澄清一下,我没有成功地尝试过:

function remove_parent_settings(){
remove_theme_support( 'thumbnail_image_width' );
remove_theme_support( 'gallery_thumbnail_image_width' );
remove_theme_support( 'single_image_width' ); } 

add_action( 'after_setup_theme', 'remove_parent_settings', 99 );

请在子主题中添加以下代码。

function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

最新更新