• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Remove Single Product Image Per Product

Add this PHP code to the end of your child themes functions file to remove a product image for 1 specific product only. Swap out the post I.D to match your single products post i.d.

add_action( 'woocommerce_before_single_product_summary', 'single_product_remove_image', 1 );
function single_product_remove_image() {
if ( is_single( '193' ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
}
}

To remove product images for more than 1 single product, add an array to the is_single conditional tag like this

add_action( 'woocommerce_before_single_product_summary', 'single_product_remove_images', 1 );
function single_product_remove_images() {
if ( is_single(array( '192','193' ) ) ) {
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
}
}

You can also use the is_product conditional tag in replace of is_single like this :

is_product('193')

And like this :

if ( is_product() AND get_the_ID() == 193 ) {

However, you should also check if WooCommerce is active like this using class_exists

if ( class_exists( 'woocommerce' ) AND is_product() AND get_the_ID() == 193 ) {

WooCommerce

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags