2014-10-09 144 views
0

我正試圖在woocommerce的SHOP頁面中獲取所有小型中等大小和完整縮略圖大小。我正在使用woocommerce.php下面的代碼(page.php文件複印件),以顯示所有產品Woocommerce產品縮略圖大小

<?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的新手,我希望通過這些不同的縮略圖大小來實現砌體佈局。任何幫助將不勝感激。 預先感謝您。

回答

0

嘗試下面的代碼:

<?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($thumbnail); 
    // Image sizes 
     // Single product image 
    update_option('shop_thumbnail_image_size', $thumbnail[$index]); // Image gallery thumbs 
} 
add_action('after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1); 
?>