I am wondering if I could change the size of one specific catalog product image.

I have many products with the same size (catalog images-not single product images, not even product thumbnails) and I want to change the size of a specific product, in order to be smaller than the other catalog images.

How can I do that?


You can use the single_product_archive_thumbnail_size filter to change which image size is used for a particular product:

function wpse_287488_product_thumbnail_size( $size ) {
    global $product;

    if ( $product->get_id() === 123 ) {
        $size = 'medium';

    return $size;
add_filter( 'single_product_archive_thumbnail_size', 'wpse_287488_product_thumbnail_size' );

Just replace medium with the registered image size you want to use. See this codex article for an overview of image sizes and how to register your own.


Without going into too much detail..

global $product;

if($product->ID == '21'):
<default code for displaying product thumb>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.