首先要在functions.php里面添加对woo的支持,并可同时设置woo图片尺寸的大小,代码如下:
add_theme_support( 'woocommerce',array(
'thumbnail_image_width' => 300,
'single_image_width' => 255,
'product_grid' => array(
'default_rows' => 10,
'min_rows' => 5,
'max_rows' => 10,
'default_columns' => 1,
'min_columns' => 1,
'max_columns' => 1
)
) );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
设置content_width, 完成此操作后,WordPress将自动将其用于oEmbed元素(YouTube视频,幻灯片共享等)的最大宽度。
function senyin_content_width() {
$GLOBALS['content_width'] = apply_filters( 'senyin_content_width', 640 );
}
add_action( 'after_setup_theme', 'senyin_content_width', 0 );
通过filter来设置不显示product短代码的show results和sorting栏,
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
add_filter( 'woocommerce_is_purchasable', '__return_false');