【发布时间】:2014-12-05 00:26:51
【问题描述】:
我正在尝试在 woocommerce 的 SHOP 页面中获取所有小型、中型和完整缩略图尺寸。我在 woocommerce.php 中使用以下代码(page.php 的副本)来显示所有产品
<?php woocommerce_content(); ?>
接下来我在functions.php中放了以下代码,但都是徒劳的
<?php
/**
* Hook in on activation
*/
/**
* Define image sizes
*/
function yourtheme_woocommerce_image_dimensions() {
global $pagenow;
if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) {
return;
}
$thumbnail = array(
'thumbnail' , 'medium' , 'large' , 'full'
);
$index = array_rand($sizes);
// Image sizes
// Single product image
update_option( 'shop_thumbnail_image_size', $sizes[$index] ); // Image gallery thumbs
}
add_action( 'after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1 );
?>
我是 woocommerce 新手,我希望使用这些不同的缩略图大小实现砌体布局。任何帮助将不胜感激。 提前谢谢你。
【问题讨论】:
标签: php wordpress size woocommerce product