How to Change the default placeholder image in WooCommerce

Change the placeholder image in WooCommerce

Change the placeholder image in WooCommerce

Adding the following WordPress code snippet to your functions.php file will allow you to change the default WooCommerce placeholder image with your own custom image file.

See Also: Add a custom field to checkout form in Woocommerce

//Change the placeholder image in WooCommerce
add_action( 'init', 'ccw_custom_woo_placeholder' );
function ccw_custom_woo_placeholder(){
	add_filter('woocommerce_placeholder_img_src','ccw_custom_placeholder_callback');
	function ccw_custom_placeholder_callback($src){
		$src = wp_get_attachment_url(121);
		return $src;
	}
}

 Note: To change placeholder image, upload your own image file to your WordPress media library and replace 121 from the above code with attachment ID of the image you have uploaded. (Recommended Image Dimensions: 450px X 450px )

 

0 Comments

Leave a Comment.