Custom Placeholder Image for Products
Replaces the grey WooCommerce placeholder with your own image for products that do not have a featured image yet.
Opens WPIDE on
Code
add_filter( 'woocommerce_placeholder_img_src', function ( $src ) {
$image_url = ''; // Full URL of your placeholder image.
return $image_url ? esc_url( $image_url ) : $src;
} );
Notes
Upload the image to the Media Library and paste its URL into $image_url.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.