Need help to add static image on woocommerce gallery?

  • Unknown's avatar

    I’ve added a second static image on woocommerce gallery, I need a third photo and so on.

    I’ve added the following code in function.php from @vijayhardaha, but it’s only up to the second image.

    /**
     * Add default image id in WC Gallery ids.
     *
     * @param array $ids Gallery image ids.
     * @return array
     */
    function wc_custom_add_default_image_in_gallery_ids( $ids ) {
    	if ( is_admin() ) {
    		return $ids;
    	}
    
    	$default_image_id = '101'; // Change 101 to your image id.
    
    	// Check ids are empty then return default image id in array.
    	if ( empty( $ids ) ) {
    		return array( $default_image_id );
    	} else {
    		// Check if ids is anarray.
    		if ( is_array( $ids ) ) {
    			// Check if image id already exists.
    			if ( ! array_value_exists( $default_image_id, $ids, true ) ) {
    				$ids[] = $default_image_id;
    			}
    		}
    	}
    
    	return $ids;
    }
    add_filter( 'woocommerce_product_get_gallery_image_ids', 'wc_custom_add_default_image_in_gallery_ids' );

    Any solution?

  • Hello there,

    Many thanks for reaching out.

    Are you able to confirm the URL of the website that you need assistance with please?

  • Unknown's avatar
  • Unknown's avatar

    Hi there!

    Thanks for the link! It seems your site is hosted on Bluehost, and so you’re using the open-source WordPress.org software. We can help with WordPress.com sites in this forum.

    There are some differences between WordPress.com and WordPress.org. If you aren’t sure about them, please check the following page that explains it: WordPress.com vs. WordPress.org.

    Since your question is specific to WooCommerce, I suggest posting it on the WooCommerce support forum here.

    Thanks!

  • The topic ‘Need help to add static image on woocommerce gallery?’ is closed to new replies.