Colorpixels Webmedia
Colorpixels Webmedia

Reputation: 11

How to hide the image of a single product on a specific pages in Woocommerce

I have woo commerce site, but in few specific product pages i don't want to show products images. How can i hide product image in specific pages only? once hide/remove product image, need to speared the text/content.

enter image description here

Upvotes: 1

Views: 374

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253814

This can be done with this simple code:

add_action( 'template_redirect', 'single_product_remove_images', 1 );
function single_product_remove_images() {
    // HERE below set your Page ID, title or slug
    if( is_page( 56 ) ){
        remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
    }
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

If you want to target a post id istead, you will use something like if( get_the_id() == 56 ){

Upvotes: 2

Related Questions